Code: status_t MediaHTTP::connect(
 const char *uri,
 const KeyedVector<String8, String8> *headers,
 off64_t /* offset */) {
 if (mInitCheck != OK) {
 return mInitCheck;
 }

 KeyedVector<String8, String8> extHeaders;
 if (headers != NULL) {
        extHeaders = *headers;
 }

 if (extHeaders.indexOfKey(String8("User-Agent")) < 0) {

         extHeaders.add(String8("User-Agent"), String8(MakeUserAgent().c_str()));
     }
 
    bool success = mHTTPConnection->connect(uri, &extHeaders);
 
     mLastHeaders = extHeaders;
    mLastURI = uri;
 
     mCachedSizeValid = false;
 
     if (success) {
        AString sanitized = uriDebugString(uri);
         mName = String8::format("MediaHTTP(%s)", sanitized.c_str());
     }
 
 return success ? OK : UNKNOWN_ERROR;
}

Vulnerability Type: Exec Code Overflow Mem. Corr. 
CWE ID: CWE-119
Summary: A remote code execution vulnerability in libstagefright in Mediaserver in Android 7.0 before 2016-11-01 could enable an attacker using a specially crafted file to cause memory corruption during media file and data processing. This issue is rated as Critical due to the possibility of remote code execution within the context of the Mediaserver process. Android ID: A-31373622.
Commit Message: Fix free-after-use for MediaHTTP

fix free-after-use when we reconnect to an HTTP media source.

Change-Id: I96da5a79f5382409a545f8b4e22a24523f287464
Tests: compilation and eyeballs
Bug: 31373622
(cherry picked from commit dd81e1592ffa77812998b05761eb840b70fed121)
