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

Lukasz Marek git at videolan.org
Thu Apr 10 05:08:40 CEST 2014


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

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

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 652a2dd..64901f2 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1599,8 +1599,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