examples : fix memory leak on failure to load gpt2 model

pull/323/head
Andy Maloney 3 years ago
parent 7282e2109e
commit 7bcd0322b2

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

Loading…
Cancel
Save