commit c8b34aa04ac8702e55ba4b8946d6794c9c6056f5
Author:     Laslo Hunhold <d...@frign.de>
AuthorDate: Fri Dec 1 09:37:28 2023 +0100
Commit:     Laslo Hunhold <d...@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 <d...@frign.de>

diff --git a/gen/util.c b/gen/util.c
index 332be82..6f21906 100644
--- 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);
 }

Reply via email to