From 45b6d734ec3e75c6d6476c5e43bd8771ecb4618d Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Tue, 20 Mar 2007 11:49:55 +0000 Subject: [PATCH] ext/vorbis/vorbisenc.c: If we get a zero-sized input buffer, don't pass it to libvorbis, as that marks EOS internally... Original commit message from CVS: * ext/vorbis/vorbisenc.c: (gst_vorbis_enc_chain): If we get a zero-sized input buffer, don't pass it to libvorbis, as that marks EOS internally. After that, libvorbis will buffer all input data, and encode none of it, eventually leading to memory exhaustion. --- ChangeLog | 8 ++++++++ ext/vorbis/vorbisenc.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index 31588ab..c0927d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-03-20 Michael Smith + + * ext/vorbis/vorbisenc.c: (gst_vorbis_enc_chain): + If we get a zero-sized input buffer, don't pass it to libvorbis, as + that marks EOS internally. After that, libvorbis will buffer all + input data, and encode none of it, eventually leading to memory + exhaustion. + 2007-03-19 Wim Taymans * gst/playback/gstdecodebin.c: (remove_fakesink): diff --git a/ext/vorbis/vorbisenc.c b/ext/vorbis/vorbisenc.c index 6eccdc2..f17ea4f 100644 --- a/ext/vorbis/vorbisenc.c +++ b/ext/vorbis/vorbisenc.c @@ -1149,6 +1149,12 @@ gst_vorbis_enc_chain (GstPad * pad, GstBuffer * buffer) vorbisenc->next_discont = TRUE; } + /* Sending zero samples to libvorbis marks EOS, so we mustn't do that */ + if (GST_BUFFER_SIZE (buffer) == 0) { + gst_buffer_unref (buffer); + return GST_FLOW_OK; + } + /* data to encode */ data = (gfloat *) GST_BUFFER_DATA (buffer); size = GST_BUFFER_SIZE (buffer) / (vorbisenc->channels * sizeof (float)); -- 2.7.4