lavu/opt: validate range before dereference
authorLukasz Marek <lukasz.m.luki@gmail.com>
Fri, 4 Apr 2014 17:28:45 +0000 (19:28 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 4 Apr 2014 20:09:57 +0000 (22:09 +0200)
This change make error handling simplier.
av_opt_freep_ranges may be called when some ranges are NULL,
for example after memory allocation fail.

Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavutil/opt.c

index ea2a5b7..33ebe52 100644 (file)
@@ -1613,8 +1613,10 @@ void av_opt_freep_ranges(AVOptionRanges **rangesp)
 
     for (i = 0; i < ranges->nb_ranges * ranges->nb_components; i++) {
         AVOptionRange *range = ranges->range[i];
-        av_freep(&range->str);
-        av_freep(&ranges->range[i]);
+        if (range) {
+            av_freep(&range->str);
+            av_freep(&ranges->range[i]);
+        }
     }
     av_freep(&ranges->range);
     av_freep(rangesp);