aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorGravatar Mike Frysinger <vapier@gentoo.org>2006-04-16 21:41:00 +0000
committerGravatar Mike Frysinger <vapier@gentoo.org>2006-04-16 21:41:00 +0000
commit20c22e0883a34c4ac1a8cc399134de96bbfa80ba (patch)
treeaa433dad4fffc0de76e729a15e6d7ca489b95023 /miscutils
parentbf2d9905caaf878efc6ee2b42069136634b2d92a (diff)
downloadbusybox-20c22e0883a34c4ac1a8cc399134de96bbfa80ba.tar.gz
busybox-20c22e0883a34c4ac1a8cc399134de96bbfa80ba.tar.bz2
just use the stack to kill memleak and return if user didnt give us anything to match
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/less.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index eba916a80..9d42748dc 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -659,7 +659,7 @@ static void regex_process(void)
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 @@ static void regex_process(void)
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 @@ static void regex_process(void)
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;