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

Lukasz Marek git at videolan.org
Mon Jun 23 18:52:50 CEST 2014


ffmpeg | branch: release/1.2 | Lukasz Marek <lukasz.m.luki at gmail.com> | Fri Apr  4 19:28:45 2014 +0200| [8f7ebb88b8168de4e95e2c77cc57486d1d879804] | 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=8f7ebb88b8168de4e95e2c77cc57486d1d879804
---

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

diff --git a/libavutil/opt.c b/libavutil/opt.c
index eeb72fd..4100d02 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1291,8 +1291,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