lzf: update pointer p after realloc
authorAndreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Fri, 4 Nov 2016 22:33:02 +0000 (23:33 +0100)
committerLuca Barbato <lu_zero@gentoo.org>
Mon, 7 Nov 2016 21:42:00 +0000 (22:42 +0100)
This fixes heap-use-after-free detected by AddressSanitizer.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavcodec/lzf.c

index 35b932b..0329fe0 100644 (file)
@@ -53,6 +53,7 @@ int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size)
                 ret = av_reallocp(buf, *size);
                 if (ret < 0)
                     return ret;
+                p = *buf + len;
             }
 
             bytestream2_get_buffer(gb, p, s);
@@ -75,6 +76,7 @@ int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size)
                 ret = av_reallocp(buf, *size);
                 if (ret < 0)
                     return ret;
+                p = *buf + len;
             }
 
             av_memcpy_backptr(p, off, l);