examples : fix memory leak on failure to load gpt2 model (#323)

This commit is contained in:
Andy Maloney 2022-12-23 13:19:07 -05:00 committed by GitHub
parent dc90efd504
commit 331c0bbddc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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;
}