Andy Maloney commited on
Commit
c92d0b9
·
unverified ·
1 Parent(s): e0255d4

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

Browse files
Files changed (1) hide show
  1. examples/talk/gpt-2.cpp +1 -0
examples/talk/gpt-2.cpp CHANGED
@@ -841,6 +841,7 @@ struct gpt2_context * gpt2_init(const char * path_model) {
841
 
842
  if (!gpt2_model_load(path_model, ctx->model, ctx->vocab)) {
843
  fprintf(stderr, "%s: failed to load model from '%s'\n", __func__, path_model);
 
844
  return nullptr;
845
  }
846
 
 
841
 
842
  if (!gpt2_model_load(path_model, ctx->model, ctx->vocab)) {
843
  fprintf(stderr, "%s: failed to load model from '%s'\n", __func__, path_model);
844
+ delete ctx;
845
  return nullptr;
846
  }
847