[FFmpeg-cvslog] qpeg: avoid pointless invalid memcpy()

wm4 git at videolan.org
Tue Jan 20 03:36:15 CET 2015


ffmpeg | branch: release/2.2 | wm4 <nfxjfg at googlemail.com> | Tue Jan 13 14:47:47 2015 +0100| [b1959b1719c81eb93e06fae4788200d172b7a9fd] | committer: Michael Niedermayer

qpeg: avoid pointless invalid memcpy()

If refdata was NULL, the memcpy() ended up copying the same memory
block onto itself, which is not only pointless, but also undefined
behavior.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 921706691a87c3ea5f5b92afd9b423e5f8c6e9d9)

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

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

 libavcodec/qpeg.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
index d61bcea..71f322b 100644
--- a/libavcodec/qpeg.c
+++ b/libavcodec/qpeg.c
@@ -120,12 +120,13 @@ static void av_noinline qpeg_decode_inter(QpegContext *qctx, uint8_t *dst,
     int filled = 0;
     int orig_height;
 
-    if(!refdata)
-        refdata= dst;
-
-    /* copy prev frame */
-    for(i = 0; i < height; i++)
-        memcpy(dst + (i * stride), refdata + (i * stride), width);
+    if (refdata) {
+        /* copy prev frame */
+        for (i = 0; i < height; i++)
+            memcpy(dst + (i * stride), refdata + (i * stride), width);
+    } else {
+        refdata = dst;
+    }
 
     orig_height = height;
     height--;



More information about the ffmpeg-cvslog mailing list