]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
ggml : fix minor resource leak reported by static analysis (#237)
authorCristiano Calcagno <redacted>
Sun, 18 Jun 2023 07:45:11 +0000 (09:45 +0200)
committerGitHub <redacted>
Sun, 18 Jun 2023 07:45:11 +0000 (10:45 +0300)
src/ggml.c

index e1a956007ee1690673f719087ea5d1f4dad4b5fa..467b7289e78cc7f2e042b47c7f42be90c08dbd51 100644 (file)
@@ -15446,6 +15446,7 @@ struct ggml_cgraph ggml_graph_import(const char * fname, struct ggml_context **
 
             if (!*ctx_data) {
                 fprintf(stderr, "%s: failed to create ggml context\n", __func__);
+                fclose(fin);
                 return result;
             }
         }
@@ -15456,6 +15457,7 @@ struct ggml_cgraph ggml_graph_import(const char * fname, struct ggml_context **
             const size_t ret = fread(data->data, sizeof(char), fsize, fin);
             if (ret != fsize) {
                 fprintf(stderr, "%s: failed to read %s\n", __func__, fname);
+                fclose(fin);
                 return result;
             }
         }