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

Lukasz Marek git at videolan.org
Mon Jun 23 17:55:49 CEST 2014


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

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

diff --git a/libavutil/opt.c b/libavutil/opt.c
index a367dbb..85435dd 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1507,8 +1507,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