From 83e6ae3334cbab6761b9c6c425b16db1e86d028a Mon Sep 17 00:00:00 2001 From: Mia Kanashi Date: Thu, 7 May 2026 00:17:39 +0300 Subject: [PATCH] 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. --- src/tools.c | 3 +++ 1 file changed, 3 insertions(+) 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);