OSDN Git Service

ffmpeg: Fix crash when avio_check is called
authorKeith Mok <kmok@cyngn.com>
Wed, 7 Oct 2015 23:13:00 +0000 (16:13 -0700)
committerKeith Mok <kmok@cyngn.com>
Tue, 8 Dec 2015 21:50:57 +0000 (13:50 -0800)
url_check does not guarantee url_open will be called before
(and actually it is not designed to do so)
If url_open is not called before url_check called, ffs
will be null causing the crash.

Change-Id: I0176c619eeb931ede0061003e396ee7e1407b860
(cherry picked from commit 832d93744cccf1f056f7ecdad6041e91148e9260)

utils/ffmpeg_source.cpp

index fc53e4c..ae20ad5 100644 (file)
@@ -185,6 +185,7 @@ static int android_close(URLContext *h)
     FFSource* ffs = (FFSource*)h->priv_data;
     ALOGV("android source close");
     delete ffs;
+    h->priv_data = NULL;
     return 0;
 }
 
@@ -197,7 +198,12 @@ static int android_check(URLContext *h, int mask)
 {
     FFSource* ffs = (FFSource*)h->priv_data;
 
-    if (ffs->init_check() < 0)
+    /* url_check does not guarantee url_open will be called
+     * (and actually it is not designed to do so)
+     * If url_open is not called before url_check called, ffs
+     * will be null, and we will assume everything is ok.
+     */
+    if (ffs && (ffs->init_check() < 0))
         return AVERROR(EACCES); // FIXME
 
     return (mask & AVIO_FLAG_READ);