Close data file in parse_file_with_callback() at the end - libgrapheme - unicode string library
(HTM) git clone git://git.suckless.org/libgrapheme
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit c8b34aa04ac8702e55ba4b8946d6794c9c6056f5
(DIR) parent af792ebe99c6301fb5b5436f856b9589ad0fd5ea
(HTM) Author: Laslo Hunhold <dev@frign.de>
Date: Fri, 1 Dec 2023 09:37:28 +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@frign.de>
Diffstat:
M gen/util.c | 8 ++++++++
1 file changed, 8 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/gen/util.c b/gen/util.c
@@ -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);
}