firmware-utils/mksenaofw: fix possible memory leak
authorAndrea Dalla Costa <andrea@dallacosta.me>
Sat, 11 Jan 2020 22:55:25 +0000 (23:55 +0100)
committerJo-Philipp Wich <jo@mein.io>
Tue, 14 Jan 2020 16:48:50 +0000 (17:48 +0100)
Add missing calls to `free` for variable `pmodel`.

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

index b0fb7203c330b68992c63359c2eb8857f2953805..d9ccfbc1e0422634046d6066b913c30e54398428 100644 (file)
@@ -316,10 +316,12 @@ int decode_image(const char *input_file_name, const char *output_file_name)
                        if (fread(pmodel, 1, cw_header.model_size, fp_input) !=
                                  cw_header.model_size) {
                                fprintf(stderr, "Incorrect header size reading model name!!");
+                               free(pmodel);
                                fclose(fp_input);
                                fclose(fp_output);
                                return -1;
                        }
+                       free(pmodel);
                } else {
                        fprintf(stderr, "Incorrect header size reading model name!!");
                        fclose(fp_input);