PATCH: Memory leak appending original mail
I found a memory leak. Patch attached.
Ben.
src/prepstdreply.c +1 -0
@@ -145,6 +145,7 @@ value =concatstr (3 , value," " , str);if (tmp)myfree (tmp); +myfree (str); count++; }if (str)
How tremendously embarrassing...
Note to self: The correct way to fix a memory leak is not to introduce a double free.
Revised patch attached.
Ben.
Quoted 3 lines · Ben Schmidt
I found a memory leak. Patch attached.
Ben.
src/prepstdreply.c +2 -0
@@ -145,6 +145,8 @@ value =concatstr (3 , value," " , str);if (tmp)myfree (tmp); +myfree (str); + str =NULL ; count++; }if (str)
Quoted 4 lines · Ben Schmidt
How tremendously embarrassing...
Note to self: The correct way to fix a memory leak is not to introduce a double free.
True :-)
Quoted 1 line
Revised patch attached.
I looked at the code, and got thinking. Since the loop is only entered if str is not NULL, and str is only used inside the loop, couldn't we just free str inside the loop?
Proposed patch attached.
Morten
Signature · 3 lines
Morten Shearman Kirkegaard <[email protected]> CTO, FableTech http://fabletech.com/
Index: src/prepstdreply.c
===================================================================
RCS file: /home/mmj/MMJCVS/mlmmj/src/prepstdreply.c,v retrieving revision 1.28
prepstdreply.c +1 -2
@@ -145,10 +145,9 @@ value =concatstr (3 , value," " , str);if (tmp)myfree (tmp); +myfree (str); count++; } -if (str) -myfree (str);close (mailfd); }else {log_error (LOG_ARGS ,"Could not substitute $originalmail$ (mailname == %s)" ,mailname);
Quoted 5 lines
I looked at the code, and got thinking. Since the loop is only entered if str is not NULL, and str is only used inside the loop, couldn't we just free str inside the loop?
Proposed patch attached.
Yeah, that works! Go for it!
Ben.
Quoted 7 lines · Ben Schmidt
Quoted 5 lines
I looked at the code, and got thinking. Since the loop is only entered if str is not NULL, and str is only used inside the loop, couldn't we just free str inside the loop?
Proposed patch attached.
Yeah, that works! Go for it!
Committed to CVS.
Morten
Signature · 3 lines
Morten Shearman Kirkegaard <[email protected]> CTO, FableTech http://fabletech.com/