tools/vm: Fix possible resource leak in page_owner_sort.c
PATCH 1/1 tools/vm: Fix possible resource leak in page_owner_sort.c
Fix possible resource leak in tools/vm/page_owner_sort.c
Signed-off-by Saurabh Badhwar <[email protected]>
--- tools/vm/page_owner_sort.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/vm/page_owner_sort.c +4 -1
@@ -110,6 +110,8 @@ int main(int argc, char **argv) buf =malloc (BUF_SIZE );if (!list || !buf) {printf ("Out of memory\n" ); +fclose (fin); +fclose (fout);exit (1 ); }
@@ -144,6 +146,7 @@ int main(int argc, char **argv)for (i =0 ; i < count; i++)fprintf (fout,"%d times:\n%s\n" , list2[i].num, list2[i].txt); - + +fclose (fout);return 0 ; }
Signature · 1 line
2.9.3
Am 19.02.2017 06:49, schrieb Saurabh Badhwar:
Quoted 11 lines
Fix possible resource leak in
tools/vm/page_owner_sort.cSigned-off-by Saurabh Badhwar <[email protected]>--- tools/vm/page_owner_sort.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)tools/vm/page_owner_sort.c +0
-0
tools/vm/page_owner_sort.c int main(int argc, char **argv) · line 116
Quoted 7 lines
tools/vm/page_owner_sort.c +2
-0@@ -110,6 +110,8 @@ int main(int argc, char **argv) buf =malloc (BUF_SIZE );if (!list || !buf) {printf ("Out of memory\n" ); +fclose (fin); +fclose (fout);exit (1 ); }
the is no resource leak as file pointer get closed on exit ntl it is ok the close them
but error messages should go to stderr an be more verbose.
just my 2 cents,
wh
Quoted 10 lines
tools/vm/page_owner_sort.c +2
-1@@ -144,6 +146,7 @@ int main(int argc, char **argv)for (i =0 ; i < count; i++)fprintf (fout,"%d times:\n%s\n" , list2[i].num, list2[i].txt); - + +fclose (fout);return 0 ; }