[FFmpeg-devel] [PATCH 1/4] lavu/opt: check for NULL before parsing

Lukasz Marek lukasz.m.luki2 at gmail.com
Sun Nov 9 23:22:46 CET 2014


set_string_binary crashes with called with val=NULL

Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
---
 libavutil/opt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index fca5354..bc62044 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -126,11 +126,15 @@ static int set_string_binary(void *obj, const AVOption *o, const char *val, uint
 {
     int *lendst = (int *)(dst + 1);
     uint8_t *bin, *ptr;
-    int len = strlen(val);
+    int len;
 
     av_freep(dst);
     *lendst = 0;
 
+    if (!val)
+        return AVERROR(EINVAL);
+
+    len = strlen(val);
     if (len & 1)
         return AVERROR(EINVAL);
     len /= 2;
-- 
1.9.1



More information about the ffmpeg-devel mailing list