From 53ea2f82ae4160cd53449272121dc9de31df45f8 Mon Sep 17 00:00:00 2001
From: Ponnam Srinivas
Date: Sat, 7 Oct 2017 14:57:44 +0530
Subject: [PATCH] nvbaseenc: Fix Memory leak in error case
https://bugzilla.gnome.org/show_bug.cgi?id=788243
---
sys/nvenc/gstnvbaseenc.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sys/nvenc/gstnvbaseenc.c b/sys/nvenc/gstnvbaseenc.c
index 980df67bd4..fe1ae16db6 100644
--- a/sys/nvenc/gstnvbaseenc.c
+++ b/sys/nvenc/gstnvbaseenc.c
@@ -1628,7 +1628,7 @@ gst_nv_base_enc_handle_frame (GstVideoEncoder * enc, GstVideoCodecFrame * frame)
GstVideoInfo *info = &nvenc->input_state->info;
GstFlowReturn flow = GST_FLOW_OK;
GstMapFlags in_map_flags = GST_MAP_READ;
- struct frame_state *state;
+ struct frame_state *state = NULL;
guint frame_n = 0;
g_assert (nvenc->encoder != NULL);
@@ -1649,9 +1649,9 @@ gst_nv_base_enc_handle_frame (GstVideoEncoder * enc, GstVideoCodecFrame * frame)
flow = _acquire_input_buffer (nvenc, &input_buffer);
if (flow != GST_FLOW_OK)
- return flow;
+ goto out;
if (input_buffer == NULL)
- return GST_FLOW_ERROR;
+ goto error;
state = frame->user_data;
if (!state)
@@ -1806,6 +1806,10 @@ out:
error:
flow = GST_FLOW_ERROR;
+ if (state)
+ g_free (state);
+ if (input_buffer)
+ g_free (input_buffer);
goto out;
}