diff options
| author | Mike Frysinger <vapier@gentoo.org> | 2006-04-16 21:41:00 +0000 |
|---|---|---|
| committer | Mike Frysinger <vapier@gentoo.org> | 2006-04-16 21:41:00 +0000 |
| commit | 20c22e0883a34c4ac1a8cc399134de96bbfa80ba (patch) | |
| tree | aa433dad4fffc0de76e729a15e6d7ca489b95023 /miscutils | |
| parent | bf2d9905caaf878efc6ee2b42069136634b2d92a (diff) | |
| download | busybox-w32-20c22e0883a34c4ac1a8cc399134de96bbfa80ba.tar.gz busybox-w32-20c22e0883a34c4ac1a8cc399134de96bbfa80ba.tar.bz2 busybox-w32-20c22e0883a34c4ac1a8cc399134de96bbfa80ba.zip | |
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.c | 12 |
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) | |||
| 659 | char current_line[256]; | 659 | char current_line[256]; |
| 660 | int i; | 660 | int i; |
| 661 | int j = 0; | 661 | int j = 0; |
| 662 | regex_t *pattern; | 662 | regex_t pattern; |
| 663 | 663 | ||
| 664 | /* Reset variables */ | 664 | /* Reset variables */ |
| 665 | match_lines[0] = -1; | 665 | match_lines[0] = -1; |
| @@ -667,9 +667,6 @@ static void regex_process(void) | |||
| 667 | num_matches = 0; | 667 | num_matches = 0; |
| 668 | match_found = 0; | 668 | match_found = 0; |
| 669 | 669 | ||
| 670 | pattern = (regex_t *) malloc(sizeof(regex_t)); | ||
| 671 | memset(pattern, 0, sizeof(regex_t)); | ||
| 672 | |||
| 673 | /* Get the uncompiled regular expression from the user */ | 670 | /* Get the uncompiled regular expression from the user */ |
| 674 | clear_line(); | 671 | clear_line(); |
| 675 | putchar((match_backwards) ? '?' : '/'); | 672 | putchar((match_backwards) ? '?' : '/'); |
| @@ -681,14 +678,15 @@ static void regex_process(void) | |||
| 681 | uncomp_regex[i-1] = '\0'; | 678 | uncomp_regex[i-1] = '\0'; |
| 682 | else | 679 | else |
| 683 | while((i = getchar()) != '\n' && i != EOF); | 680 | while((i = getchar()) != '\n' && i != EOF); |
| 684 | } | 681 | } else |
| 682 | return; | ||
| 685 | 683 | ||
| 686 | /* Compile the regex and check for errors */ | 684 | /* Compile the regex and check for errors */ |
| 687 | xregcomp(pattern, uncomp_regex, 0); | 685 | xregcomp(&pattern, uncomp_regex, 0); |
| 688 | 686 | ||
| 689 | /* Run the regex on each line of the current file here */ | 687 | /* Run the regex on each line of the current file here */ |
| 690 | for (i = 0; i <= num_flines; i++) { | 688 | for (i = 0; i <= num_flines; i++) { |
| 691 | strcpy(current_line, process_regex_on_line(flines[i], pattern)); | 689 | strcpy(current_line, process_regex_on_line(flines[i], &pattern)); |
| 692 | flines[i] = bb_xstrdup(current_line); | 690 | flines[i] = bb_xstrdup(current_line); |
| 693 | if (match_found) { | 691 | if (match_found) { |
| 694 | match_lines[j] = i; | 692 | match_lines[j] = i; |
