diff options
Diffstat (limited to 'libbb/fgets_str.c')
-rw-r--r-- | libbb/fgets_str.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libbb/fgets_str.c b/libbb/fgets_str.c index 8f06fa59c..41370d176 100644 --- a/libbb/fgets_str.c +++ b/libbb/fgets_str.c | |||
@@ -44,12 +44,14 @@ char *fgets_str(FILE *file, const char *terminating_string) | |||
44 | 44 | ||
45 | /* Check for terminating string */ | 45 | /* Check for terminating string */ |
46 | end_string_offset = idx - term_length; | 46 | end_string_offset = idx - term_length; |
47 | if ((end_string_offset > 0) && (memcmp(&linebuf[end_string_offset], terminating_string, term_length) == 0)) { | 47 | if (end_string_offset > 0 |
48 | && memcmp(&linebuf[end_string_offset], terminating_string, term_length) == 0 | ||
49 | ) { | ||
48 | idx -= term_length; | 50 | idx -= term_length; |
49 | break; | 51 | break; |
50 | } | 52 | } |
51 | } | 53 | } |
54 | linebuf = xrealloc(linebuf, idx + 1); | ||
52 | linebuf[idx] = '\0'; | 55 | linebuf[idx] = '\0'; |
53 | return(linebuf); | 56 | return linebuf; |
54 | } | 57 | } |
55 | |||