svn commit: trunk/busybox/miscutils

vapier at busybox.net vapier at busybox.net
Sun Apr 16 21:41:02 UTC 2006


Author: vapier
Date: 2006-04-16 14:41:00 -0700 (Sun, 16 Apr 2006)
New Revision: 14897

Log:
just use the stack to kill memleak and return if user didnt give us anything to match

Modified:
   trunk/busybox/miscutils/less.c


Changeset:
Modified: trunk/busybox/miscutils/less.c
===================================================================
--- trunk/busybox/miscutils/less.c	2006-04-16 21:30:47 UTC (rev 14896)
+++ trunk/busybox/miscutils/less.c	2006-04-16 21:41:00 UTC (rev 14897)
@@ -659,7 +659,7 @@
 	char current_line[256];
 	int i;
 	int j = 0;
-	regex_t *pattern;
+	regex_t pattern;
 
 	/* Reset variables */
 	match_lines[0] = -1;
@@ -667,9 +667,6 @@
 	num_matches = 0;
 	match_found = 0;
 
-	pattern = (regex_t *) malloc(sizeof(regex_t));
-	memset(pattern, 0, sizeof(regex_t));
-
 	/* Get the uncompiled regular expression from the user */
 	clear_line();
 	putchar((match_backwards) ? '?' : '/');
@@ -681,14 +678,15 @@
 			uncomp_regex[i-1] = '\0';
 		else
 			while((i = getchar()) != '\n' && i != EOF);
-	}
+	} else
+		return;
 
 	/* Compile the regex and check for errors */
-	xregcomp(pattern, uncomp_regex, 0);
+	xregcomp(&pattern, uncomp_regex, 0);
 
 	/* Run the regex on each line of the current file here */
 	for (i = 0; i <= num_flines; i++) {
-		strcpy(current_line, process_regex_on_line(flines[i], pattern));
+		strcpy(current_line, process_regex_on_line(flines[i], &pattern));
 		flines[i] = bb_xstrdup(current_line);
 		if (match_found) {
 			match_lines[j] = i;




More information about the busybox-cvs mailing list