OSDN Git Service

Avoid memory leaks when handling metadata strings
authorDavid Williams <david.williams@sonymobile.com>
Mon, 19 Nov 2012 08:52:16 +0000 (09:52 +0100)
committerGerrit Code Review <noreply-gerritcodereview@google.com>
Tue, 20 Nov 2012 20:27:56 +0000 (12:27 -0800)
Don't duplicate strings when retrieveing metadata from media
files. As any requests for metadata strings would pass through
the binder, this would cause the reference to the duplicate string
to be lost, causing a memory leak as the duplicate would not be
freed.

Change-Id: I2593733472b1bb589bc502b2c11080f581015bb5

media/libstagefright/StagefrightMetadataRetriever.cpp

index a2f3f13..19af4fb 100644 (file)
@@ -433,7 +433,7 @@ const char *StagefrightMetadataRetriever::extractMetadata(int keyCode) {
         return NULL;
     }
 
-    return strdup(mMetaData.valueAt(index).string());
+    return mMetaData.valueAt(index).string();
 }
 
 void StagefrightMetadataRetriever::parseMetaData() {