Skip to content

Commit c9532ab

Browse files
authored
Merge pull request #71 from sadeem-albir/patch-12
Fix readlines.c
2 parents 4c99fed + 1fbf053 commit c9532ab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

chapter_5/exercise_5_07/readlines.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int readlines(char *line_ptr[], int max_nr_of_lines, char *stored_lines)
4848
{
4949
// Checking if the current # of lines exceeds the max # of lines that can be stored
5050
// Also checking if the max # of chars from the stored_lines buffer is not exceeded
51-
if (nr_of_lines >= max_nr_of_lines || (strlen(stored_lines) + len) > MAXSTORE)
51+
if (nr_of_lines >= max_nr_of_lines || stored_lines + MAXSTORE - p < len)
5252
{
5353
return -1;
5454
}

0 commit comments

Comments
 (0)