Spaces:
Running
Running
Andy Maloney
commited on
examples : fix memory leak on failure to load gpt2 model (#323)
Browse files- 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 |
|