pngenc: fix memory leak in error code path

Don't leak row_pointers if frame can't be mapped.

https://bugzilla.gnome.org/show_bug.cgi?id=787885
This commit is contained in:
Ponnam Srinivas 2017-09-20 09:37:59 +05:30 committed by Tim-Philipp Müller
parent fb26575b73
commit c53bee067d

View file

@ -304,7 +304,6 @@ gst_pngenc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame)
png_set_write_fn (pngenc->png_struct_ptr, pngenc,
(png_rw_ptr) user_write_data, user_flush_data);
row_pointers = g_new (png_byte *, GST_VIDEO_INFO_HEIGHT (info));
if (!gst_video_frame_map (&vframe, &pngenc->input_state->info,
frame->input_buffer, GST_MAP_READ)) {
GST_ELEMENT_ERROR (pngenc, STREAM, FORMAT, (NULL),
@ -313,6 +312,8 @@ gst_pngenc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame)
goto done;
}
row_pointers = g_new (png_byte *, GST_VIDEO_INFO_HEIGHT (info));
for (row_index = 0; row_index < GST_VIDEO_INFO_HEIGHT (info); row_index++) {
row_pointers[row_index] = GST_VIDEO_FRAME_COMP_DATA (&vframe, 0) +
(row_index * GST_VIDEO_FRAME_COMP_STRIDE (&vframe, 0));