mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-08 06:26:10 +02:00
MEDIUM: tools: read_line_to_trash() handle empty files without \n
fgets() returns NULL when EOF is reached before newline, handle that as a success for consistency, current behaviour is arguably a bug, the API of fgets() is pretty weird after all so someone probably forgot.
This commit is contained in:
parent
faf3e9ac3a
commit
83e6ae3334
@ -6906,6 +6906,9 @@ ssize_t read_line_to_trash(const char *path_fmt, ...)
|
||||
trash.data--;
|
||||
trash.area[trash.data] = 0;
|
||||
ret = trash.data; // success
|
||||
} else if (feof(file)) {
|
||||
/* empty file is allowed */
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user