ext/ffmpeg/gstffmpegenc.c: Fix segmentation fault and memleak.

Original commit message from CVS:
Reviewed by : Edward Hervey  <edward@fluendo.com>
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_chain_audio):
Fix segmentation fault and memleak.
Fixes #332995 and #333001
This commit is contained in:
Edward Hervey 2006-03-01 15:05:03 +00:00
parent 2f6def3134
commit a96a9ed0c5
2 changed files with 11 additions and 5 deletions

View file

@ -1,3 +1,11 @@
2006-03-01 Josef Zlomek <josef dot zlomek at itonis dot tv>
Reviewed by : Edward Hervey <edward@fluendo.com>
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_chain_audio):
Fix segmentation fault and memleak.
Fixes #332995 and #333001
2006-02-24 Tim-Philipp Müller <tim at centricular dot net> 2006-02-24 Tim-Philipp Müller <tim at centricular dot net>
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_frame): * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_frame):

View file

@ -578,8 +578,7 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstBuffer * inbuf)
if (in_size > size) { if (in_size > size) {
/* this is panic! we got a buffer, but still don't have enough /* this is panic! we got a buffer, but still don't have enough
* data. Merge them and retry in the next cycle... */ * data. Merge them and retry in the next cycle... */
ffmpegenc->cache = gst_buffer_span (ffmpegenc->cache, 0, inbuf, ffmpegenc->cache = gst_buffer_join (ffmpegenc->cache, inbuf);
GST_BUFFER_SIZE (ffmpegenc->cache) + GST_BUFFER_SIZE (inbuf));
} else if (in_size == size) { } else if (in_size == size) {
/* exactly the same! how wonderful */ /* exactly the same! how wonderful */
ffmpegenc->cache = inbuf; ffmpegenc->cache = inbuf;
@ -605,8 +604,7 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstBuffer * inbuf)
subbuf = gst_buffer_create_sub (inbuf, 0, frame_size - (in_size - size)); subbuf = gst_buffer_create_sub (inbuf, 0, frame_size - (in_size - size));
GST_BUFFER_DURATION (subbuf) = GST_BUFFER_DURATION (subbuf) =
GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size; GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
subbuf = gst_buffer_span (ffmpegenc->cache, 0, subbuf, subbuf = gst_buffer_join (ffmpegenc->cache, subbuf);
GST_BUFFER_SIZE (ffmpegenc->cache) + GST_BUFFER_SIZE (subbuf));
ffmpegenc->cache = NULL; ffmpegenc->cache = NULL;
} else { } else {
subbuf = gst_buffer_create_sub (inbuf, size - in_size, frame_size); subbuf = gst_buffer_create_sub (inbuf, size - in_size, frame_size);
@ -617,7 +615,7 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstBuffer * inbuf)
(size - in_size) / size); (size - in_size) / size);
} }
outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (inbuf)); outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (subbuf));
ret_size = avcodec_encode_audio (ffmpegenc->context, ret_size = avcodec_encode_audio (ffmpegenc->context,
GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (outbuf),
GST_BUFFER_SIZE (outbuf), (const short int *) GST_BUFFER_SIZE (outbuf), (const short int *)