From: Andy Maloney Date: Fri, 23 Dec 2022 18:19:07 +0000 (-0500) Subject: examples : fix memory leak on failure to load gpt2 model (#323) X-Git-Tag: upstream/1.7.4~1674 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=331c0bbddc112231b6e896166519e64831f42f9d;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp examples : fix memory leak on failure to load gpt2 model (#323) --- diff --git a/examples/talk/gpt-2.cpp b/examples/talk/gpt-2.cpp index c50157fc..c28644de 100644 --- a/examples/talk/gpt-2.cpp +++ b/examples/talk/gpt-2.cpp @@ -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; }