Skip to content

Commit

Permalink
Merge pull request #71 from sadeem-albir/patch-12
Browse files Browse the repository at this point in the history
Fix readlines.c
  • Loading branch information
ohkimur authored Apr 1, 2024
2 parents 4c99fed + 1fbf053 commit c9532ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion chapter_5/exercise_5_07/readlines.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int readlines(char *line_ptr[], int max_nr_of_lines, char *stored_lines)
{
// Checking if the current # of lines exceeds the max # of lines that can be stored
// Also checking if the max # of chars from the stored_lines buffer is not exceeded
if (nr_of_lines >= max_nr_of_lines || (strlen(stored_lines) + len) > MAXSTORE)
if (nr_of_lines >= max_nr_of_lines || stored_lines + MAXSTORE - p < len)
{
return -1;
}
Expand Down

0 comments on commit c9532ab

Please sign in to comment.