Red Hat Bugzilla – Bug 171587
More cleanups and fixes for memory leaks
Last modified: 2007-11-30 17:11:15 EST
Hi, I have created another patch to fix some memory leaks, close files and do
cleanups. It contains:
- free() and close() where needed;
- defConfig setup moved from logrotate.c to config.c;
- pointers of compression options are set only by allocated strings, so I could
include them in free_logInfo(), to free() properly when someone set them by
- new function createOutputFile(), which contains code that was duplicated in
three functions of logrotate.c;
- other minor things, let's see if this time I didn't break something.
- In copyTruncate() (logrotate.c), I have changed the creation of output
file to use the new function createOutputFile(), but before the open() function
was between two blocks of SELINUX code and the fchmod/fchown functions were
after the second block. Now the fchmod/fchown() functions are inside the
function createOutputFile, which I put between the two blocks of SELINUX, as the
open() function was localized. I don't know how SELINUX work, so I need help
from someone to tell if this change can be a problem.
Created attachment 120296 [details]
Patch for cleanups and memory leaks fixes
Created attachment 120302 [details]
New version of the patch, that removes one more line which was causing problems.
U wanted type "free(newlog->uncompress_prog);" in hunk @@ -903,6 +927,7 @@ didn't u?
Yes, I forgot to change that after copy & paste, sorry.
Created attachment 120313 [details]