[FFmpeg-cvslog] lavu/opt: validate range before dereference

Lukasz Marek git at videolan.org
Wed Jun 25 17:01:28 CEST 2014


ffmpeg | branch: release/2.0 | Lukasz Marek <lukasz.m.luki at gmail.com> | Fri Apr  4 19:28:45 2014 +0200| [c61c66cfb17e3552689020f0ef228b149ab42627] | committer: Michael Niedermayer

lavu/opt: validate range before dereference

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 at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 3aac5fcfa9d3748659d78ab2a66d0ccce22cfd4f)

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

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

 libavutil/opt.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 24511de..15b681c 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1430,8 +1430,10 @@ void av_opt_freep_ranges(AVOptionRanges **rangesp)
 
     for (i = 0; i < ranges->nb_ranges; 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);



More information about the ffmpeg-cvslog mailing list