Extra checks, fixed cleanup in file generating routine - fiche - A pastebin adjusted for gopher use
 (HTM) git clone git://vernunftzentrum.de/fiche.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 53c0027b3c38a0a253d975747037507780833d3c
 (DIR) parent 7575609c415f84320b7956279d4d2adef8a5228e
 (HTM) Author: solusipse <solus1ps3@gmail.com>
       Date:   Sat,  2 Sep 2017 19:48:02 +0200
       
       Extra checks, fixed cleanup in file generating routine
       
       Diffstat:
         fiche.c                             |       7 +++++++
       
       1 file changed, 7 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/fiche.c b/fiche.c
       @@ -705,6 +705,10 @@ static void generate_slug(char **output, uint8_t length, uint8_t extra_length) {
        
        
        static int create_directory(char *output_dir, char *slug) {
       +    if (!slug) {
       +        return -1;
       +    }
       +
            // Additional byte is for the slash
            size_t len = strlen(output_dir) + strlen(slug) + 2;
        
       @@ -740,10 +744,13 @@ static int save_to_file(uint8_t *data, char *output_dir, char *slug) {
            // Attempt file saving
            FILE *f = fopen(path, "w");
            if (!f) {
       +        free(path);
                return -1;
            }
        
            if ( fprintf(f, "%s", data) < 0 ) {
       +        fclose(f);
       +        free(path);
                return -1;
            }