History

lavfi/dnn_backend_tensorflow.c: fix mem leak in load_tf_model

Ting Fu committed 5 years ago

Commit 3499ec81 parent a4e518c1 file · +8 −0Browse files

Unified · Split

libavfilter/dnn/dnn_backend_tf.c+8−0
@@ -282,6 +282,9 @@ static DNNReturnType load_tf_model(TFModel *tf_model, const char *model_filename · 281 unmodified lines
282282 TF_SetConfig(sess_opts, sess_config, sess_config_length,tf_model->status);
283283 av_freep(&sess_config);
284284 if (TF_GetCode(tf_model->status) != TF_OK) {
285+ TF_DeleteGraph(tf_model->graph);
286+ TF_DeleteStatus(tf_model->status);
287+ TF_DeleteSessionOptions(sess_opts);
285288 av_log(ctx, AV_LOG_ERROR, "Failed to set config for sess options with %s\n",
286289 tf_model->ctx.options.sess_config);
287290 return DNN_ERROR;
@@ -292,6 +295,8 @@ static DNNReturnType load_tf_model(TFModel *tf_model, const char *model_filename · 4 unmodified lines
292295 TF_DeleteSessionOptions(sess_opts);
293296 if (TF_GetCode(tf_model->status) != TF_OK)
294297 {
298+ TF_DeleteGraph(tf_model->graph);
299+ TF_DeleteStatus(tf_model->status);
295300 av_log(ctx, AV_LOG_ERROR, "Failed to create new session with model graph\n");
296301 return DNN_ERROR;
297302 }
@@ -304,6 +309,9 @@ static DNNReturnType load_tf_model(TFModel *tf_model, const char *model_filename · 6 unmodified lines
304309 &init_op, 1, NULL, tf_model->status);
305310 if (TF_GetCode(tf_model->status) != TF_OK)
306311 {
312+ TF_DeleteSession(tf_model->session, tf_model->status);
313+ TF_DeleteGraph(tf_model->graph);
314+ TF_DeleteStatus(tf_model->status);
307315 av_log(ctx, AV_LOG_ERROR, "Failed to run session when initializing\n");
308316 return DNN_ERROR;
309317 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t