svn commit: branches/busybox_scratch/coreutils

aldot at busybox.net aldot at busybox.net
Mon Aug 28 16:45:51 UTC 2006


Author: aldot
Date: 2006-08-28 09:45:51 -0700 (Mon, 28 Aug 2006)
New Revision: 16002

Log:
- fix segfault caused by freeing inproper *line; Thanks to Breeze for noticing
  Add optional freeing of cut_lists so we don't leak any mem at all.


Modified:
   branches/busybox_scratch/coreutils/cut.c


Changeset:
Modified: branches/busybox_scratch/coreutils/cut.c
===================================================================
--- branches/busybox_scratch/coreutils/cut.c	2006-08-28 13:46:38 UTC (rev 16001)
+++ branches/busybox_scratch/coreutils/cut.c	2006-08-28 16:45:51 UTC (rev 16002)
@@ -55,7 +55,8 @@
 	while ((line = bb_get_chomped_line_from_file(file)) != NULL) {
 
 		/* set up a list so we can keep track of what's been printed */
-		char * const printed = xzalloc(strlen(line) * sizeof(char));
+		char * printed = xzalloc(strlen(line) * sizeof(char));
+		char * orig_line = line;
 		unsigned int cl_pos = 0;
 		int spos;
 
@@ -158,7 +159,7 @@
 	  next_line:
 		linenum++;
 		free(printed);
-		free(line);
+		free(orig_line);
 	}
 }
 
@@ -294,6 +295,7 @@
 			}
 		}
 	}
-
+	if (ENABLE_FEATURE_CLEAN_UP)
+		free(cut_lists);
 	return EXIT_SUCCESS;
 }




More information about the busybox-cvs mailing list