nfs-server-generator: fix a potential memory leak issue
Subsystems (2)
PATCH 1/1 nfs-server-generator: fix a potential memory leak issue
---
Fix a potential memory leak issue caused by unfree pathname 'path'.
systemd/nfs-server-generator.c | 1 + 1 file changed, 1 insertion(+)
systemd/nfs-server-generator.c +1 -0
@@ -139,6 +139,7 @@ int main(int argc, char *argv[])strcat (path, filebase); f =fopen (path,"w" );if (!f) +free (path);exit (1 );fprintf (f,"# Automatically generated by nfs-server-generator\n\n[Unit]\n" );
Signature · 1 line
2.7.4
Quoted 12 lines · ChunYu Wang
Signed-off-by ChunYu Wang <[email protected]>---
Fix a potential memory leak issue caused by unfree pathname 'path'.systemd/nfs-server-generator.c | 1 + 1 file changed, 1 insertion(+)systemd/nfs-server-generator.c +0
-0
systemd/nfs-server-generator.c int main(int argc, char *argv[]) · line 143
Quoted 5 lines
systemd/nfs-server-generator.c +1
-0@@ -139,6 +139,7 @@ int main(int argc, char *argv[])strcat (path, filebase); f =fopen (path,"w" );if (!f) +free (path);exit (1 );
First of all you need some '{' '}' so the process will not always exit when f != NULL...
Secondly dead process don't leak memory. :-) They don't leak anything... they are died! ;-)
steved.
Quoted 3 lines
systemd/nfs-server-generator.c +0
-0fprintf (f,"# Automatically generated by nfs-server-generator\n\n[Unit]\n" );
En, yes,
Thanks for reviewing and reminding, it is my fault [ : ( ].
Valgrind did not notice me about the syntax rationality, but it's my duty. Get down to learn, and thanks a lot.
Regards,
ChunYu Wang
Quoted 30 lines · Steve Dickson
Quoted 12 lines · ChunYu Wang
Signed-off-by ChunYu Wang <[email protected]>---
Fix a potential memory leak issue caused by unfree pathname 'path'.systemd/nfs-server-generator.c | 1 + 1 file changed, 1 insertion(+)systemd/nfs-server-generator.c +0
-0systemd/nfs-server-generator.c int main(int argc, char *argv[]) · line 143
Quoted 5 lines
systemd/nfs-server-generator.c +1
-0@@ -139,6 +139,7 @@ int main(int argc, char *argv[])strcat (path, filebase); f =fopen (path,"w" );if (!f) +free (path);exit (1 );First of all you need some '{' '}' so the process will not always exit when f != NULL...
Secondly dead process don't leak memory. :-) They don't leak anything... they are died! ;-)
steved.
Quoted 3 lines
systemd/nfs-server-generator.c +0
-0fprintf (f,"# Automatically generated by nfs-server-generator\n\n[Unit]\n" );