[FFmpeg-cvslog] mem: Handle av_reallocp(..., 0) properly

Martin Storsjö git at videolan.org
Sat Sep 21 09:39:18 CEST 2013


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Fri Sep 20 14:02:41 2013 +0300| [67e285ceca1cb602a5ab87010b30d904527924fe] | committer: Martin Storsjö

mem: Handle av_reallocp(..., 0) properly

Previously this did a double free (and returned an error).

Reported-by: Justin Ruggles
Signed-off-by: Martin Storsjö <martin at martin.st>

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

 libavutil/mem.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavutil/mem.c b/libavutil/mem.c
index 172180e..b84020c 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -141,6 +141,10 @@ int av_reallocp(void *ptr, size_t size)
     void **ptrptr = ptr;
     void *ret;
 
+    if (!size) {
+        av_freep(ptr);
+        return 0;
+    }
     ret = av_realloc(*ptrptr, size);
 
     if (!ret) {



More information about the ffmpeg-cvslog mailing list