From: Mia Kanashi Date: Wed, 6 May 2026 21:17:39 +0000 (+0300) Subject: MEDIUM: tools: read_line_to_trash() handle empty files without \n X-Git-Tag: v3.4-dev11~16 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=83e6ae3334cbab6761b9c6c425b16db1e86d028a;p=haproxy.git 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. --- diff --git a/src/tools.c b/src/tools.c index 3adc7cf3f..268951629 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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);