]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
examples : fix memory leak on failure to load gpt2 model (#323)
authorAndy Maloney <redacted>
Fri, 23 Dec 2022 18:19:07 +0000 (13:19 -0500)
committerGitHub <redacted>
Fri, 23 Dec 2022 18:19:07 +0000 (20:19 +0200)
examples/talk/gpt-2.cpp

index c50157fc8ce7204680a5d3e342cb1314d9982d0f..c28644de3a46a9c93a285447f98396c526d5ec05 100644 (file)
@@ -841,6 +841,7 @@ struct gpt2_context * gpt2_init(const char * path_model) {
 
         if (!gpt2_model_load(path_model, ctx->model, ctx->vocab)) {
             fprintf(stderr, "%s: failed to load model from '%s'\n", __func__, path_model);
+            delete ctx;
             return nullptr;
         }