[FFmpeg-cvslog] avcodec/g723_1: fix writing into input frame data and warning

Michael Niedermayer git at videolan.org
Mon May 26 21:05:34 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon May 26 20:37:34 2014 +0200| [d35000c2dcb7a5d27c3e1c1d06f9291df177081a] | committer: Michael Niedermayer

avcodec/g723_1: fix writing into input frame data and warning

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d35000c2dcb7a5d27c3e1c1d06f9291df177081a
---

 libavcodec/g723_1.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c
index e4bde2a..66afd6a 100644
--- a/libavcodec/g723_1.c
+++ b/libavcodec/g723_1.c
@@ -2346,11 +2346,15 @@ static int g723_1_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     int16_t weighted_lpc[LPC_ORDER * SUBFRAMES << 1];
     int16_t vector[FRAME_LEN + PITCH_MAX];
     int offset, ret;
-    int16_t *in = (const int16_t *)frame->data[0];
+    int16_t *in_orig = av_memdup(frame->data[0], frame->nb_samples * sizeof(int16_t));
+    int16_t *in = in_orig;
 
     HFParam hf[4];
     int i, j;
 
+    if (!in)
+        return AVERROR(ENOMEM);
+
     highpass_filter(in, &p->hpf_fir_mem, &p->hpf_iir_mem);
 
     memcpy(vector, p->prev_data, HALF_FRAME_LEN * sizeof(int16_t));
@@ -2456,6 +2460,8 @@ static int g723_1_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
         offset += LPC_ORDER;
     }
 
+    av_freep(&in_orig); in = NULL;
+
     if ((ret = ff_alloc_packet2(avctx, avpkt, 24)) < 0)
         return ret;
 



More information about the ffmpeg-cvslog mailing list