[PATCH] tools/vm/page_owner_sort.c: Fix the potential stack overflow risk
From: Tang Bin
Date: Thu May 06 2021 - 09:22:35 EST
Add judgment to fix the potential stack overflow risk
Signed-off-by: Zhang Shengju <zhangshengju@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Tang Bin <tangbin@xxxxxxxxxxxxxxxxxxxx>
---
tools/vm/page_owner_sort.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/vm/page_owner_sort.c b/tools/vm/page_owner_sort.c
index 85eb65ea1..bb7c35b77 100644
--- a/tools/vm/page_owner_sort.c
+++ b/tools/vm/page_owner_sort.c
@@ -132,6 +132,10 @@ int main(int argc, char **argv)
qsort(list, list_size, sizeof(list[0]), compare_txt);
list2 = malloc(sizeof(*list) * list_size);
+ if (!list2) {
+ printf("Out of memory\n");
+ exit(1);
+ }
printf("culling\n");
--
2.20.1.windows.1