OSDN Git Service

Fix free-after-use for MediaHTTP
authorRay Essick <essick@google.com>
Tue, 13 Sep 2016 18:43:17 +0000 (11:43 -0700)
committerRay Essick <essick@google.com>
Tue, 13 Sep 2016 21:29:01 +0000 (14:29 -0700)
fix free-after-use when we reconnect to an HTTP media source.

Change-Id: I96da5a79f5382409a545f8b4e22a24523f287464
Tests: compilation and eyeballs
Bug: 31373622

media/libstagefright/http/MediaHTTP.cpp

index 76ec625..5b18814 100644 (file)
@@ -58,15 +58,19 @@ status_t MediaHTTP::connect(
         extHeaders.add(String8("User-Agent"), String8(MakeUserAgent().c_str()));
     }
 
-    bool success = mHTTPConnection->connect(uri, &extHeaders);
+    mLastURI = uri;
+    // reconnect() calls with uri == old mLastURI.c_str(), which gets zapped
+    // as part of the above assignment. Ensure no accidental later use.
+    uri = NULL;
+
+    bool success = mHTTPConnection->connect(mLastURI.c_str(), &extHeaders);
 
     mLastHeaders = extHeaders;
-    mLastURI = uri;
 
     mCachedSizeValid = false;
 
     if (success) {
-        AString sanitized = uriDebugString(uri);
+        AString sanitized = uriDebugString(mLastURI);
         mName = String8::format("MediaHTTP(%s)", sanitized.c_str());
     }