mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 07:56:31 +01:00
Fix infinite loop in peek_line for EOF blanks
This commit is contained in:
parent
af87c7a1af
commit
85a5c8dabd
1 changed files with 2 additions and 0 deletions
|
@ -56,6 +56,8 @@ char *peek_line(FILE *file, int line_offset, long *position) {
|
|||
for (int i = 0; i <= line_offset; i++) {
|
||||
ssize_t read = getline(&line, &length, file);
|
||||
if (read < 0) {
|
||||
free(line);
|
||||
line = NULL;
|
||||
break;
|
||||
}
|
||||
if (read > 0 && line[read - 1] == '\n') {
|
||||
|
|
Loading…
Reference in a new issue