summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MPEG4Extractor.cpp
diff options
context:
space:
mode:
authorJens Gulin <jens.gulin@sonymobile.com>2012-09-10 15:54:40 +0200
committerJohan Redestig <johan.redestig@sonymobile.com>2012-11-19 10:38:57 +0100
commit1552217cca4d949bba4b2cf6194a0936bbb10fa4 (patch)
tree318003ed45bd3441b609284933961f85cc79fc32 /media/libstagefright/MPEG4Extractor.cpp
parent33cf49b168a88a88167c46b01787a57b49cd875f (diff)
downloadframeworks_av-1552217cca4d949bba4b2cf6194a0936bbb10fa4.zip
frameworks_av-1552217cca4d949bba4b2cf6194a0936bbb10fa4.tar.gz
frameworks_av-1552217cca4d949bba4b2cf6194a0936bbb10fa4.tar.bz2
Memory leak solved in MPEG4Extractor::parseChunk for cover art
Repeated leaks detected in mediaserver context. Most chunks small but some bigger. Adding up it was not uncommon to see 200Mb footprint. libc memdebug allocation call stack showed the root cause in "covr" parsing - that explains why content often was empty but sometimes big. Change-Id: I0de6c1eeef174d2529973ff9c6a020ec3dd44c75
Diffstat (limited to 'media/libstagefright/MPEG4Extractor.cpp')
-rw-r--r--media/libstagefright/MPEG4Extractor.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index dc8e4a3..6929765 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -30,6 +30,7 @@
#include <string.h>
#include <media/stagefright/foundation/ABitReader.h>
+#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/DataSource.h>
@@ -1426,18 +1427,15 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
if (mFileMetaData != NULL) {
ALOGV("chunk_data_size = %lld and data_offset = %lld",
chunk_data_size, data_offset);
- uint8_t *buffer = new uint8_t[chunk_data_size + 1];
+ sp<ABuffer> buffer = new ABuffer(chunk_data_size + 1);
if (mDataSource->readAt(
- data_offset, buffer, chunk_data_size) != (ssize_t)chunk_data_size) {
- delete[] buffer;
- buffer = NULL;
-
+ data_offset, buffer->data(), chunk_data_size) != (ssize_t)chunk_data_size) {
return ERROR_IO;
}
const int kSkipBytesOfDataBox = 16;
mFileMetaData->setData(
kKeyAlbumArt, MetaData::TYPE_NONE,
- buffer + kSkipBytesOfDataBox, chunk_data_size - kSkipBytesOfDataBox);
+ buffer->data() + kSkipBytesOfDataBox, chunk_data_size - kSkipBytesOfDataBox);
}
*offset += chunk_size;