firmware-utils/mktitanimg: fix possible resource leak
authorAndrea Dalla Costa <andrea@dallacosta.me>
Sat, 11 Jan 2020 23:05:55 +0000 (00:05 +0100)
committerJo-Philipp Wich <jo@mein.io>
Tue, 14 Jan 2020 16:48:50 +0000 (17:48 +0100)
Add missing call to `fclose` for file pointer `nsp_image`.

Signed-off-by: Andrea Dalla Costa <andrea@dallacosta.me>
tools/firmware-utils/src/mktitanimg.c

index cca4a0ebaece6b9d0aab173108465fc8abdee946..120d08f0c4fb7eee81031f1b3ebe7079a5cc39c4 100644 (file)
@@ -225,6 +225,7 @@ int main(int argc, char* argv[], char* env[])
                        if(fwrite((void*)buf,1,padding,nsp_image)!=padding) {
                                printf("ERROR: can't write to %s.\n", filen_out);
                                free(buf);
+                               fclose(nsp_image);
                                return -1;
                        }
                        free(buf);