[hackers] [libgrapheme] Close data file in parse_file_with_callback() at the end || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Fri, 1 Dec 2023 09:39:52 +0100 (CET)

commit c8b34aa04ac8702e55ba4b8946d6794c9c6056f5
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Fri Dec 1 09:37:28 2023 +0100
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Fri Dec 1 09:39:38 2023 +0100

    Close data file in parse_file_with_callback() at the end
    
    This otherwise leads to build problems on macOS because of too many
    open files due to leaked file descriptors.
    
    Thank you, zeromake (https://blog.zeromake.com), for reporting this!
    
    Signed-off-by: Laslo Hunhold <dev_AT_frign.de>

diff --git a/gen/util.c b/gen/util.c
index 332be82..6f21906 100644
--- a/gen/util.c
+++ b/gen/util.c
_AT_@ -282,6 +282,14 @@ parse_file_with_callback(const char *fname,
                 }
         }
 
+ /* close file */
+ if (fclose(fp)) {
+ fprintf(stderr, "parse_file_with_callback: fclose '%s': %s.\n",
+ fname, strerror(errno));
+ exit(1);
+ }
+
+ /* cleanup */
         free(line);
         free(field);
 }
Received on Fri Dec 01 2023 - 09:39:52 CET

This archive was generated by hypermail 2.3.0 : Fri Dec 01 2023 - 09:48:36 CET