summaryrefslogtreecommitdiffstats
path: root/media/libmedia
diff options
context:
space:
mode:
authorOscar Rydhé <oscar.rydhe@sonymobile.com>2013-01-22 11:09:54 +0100
committerTakeshi Aimi <takeshi.aimi@sonymobile.com>2014-01-23 18:40:31 +0900
commit6d39eb9d7da2ca8eb733f2d2eba686c56b24885b (patch)
treedc68f714fc4ecb87102ca9d52a29346be7bd60b4 /media/libmedia
parent96a7b5a9c87ec3f8cadad5bffc06a82f9f4d86d8 (diff)
downloadframeworks_av-6d39eb9d7da2ca8eb733f2d2eba686c56b24885b.zip
frameworks_av-6d39eb9d7da2ca8eb733f2d2eba686c56b24885b.tar.gz
frameworks_av-6d39eb9d7da2ca8eb733f2d2eba686c56b24885b.tar.bz2
Do partial reads in MemoryLeakTrackUtil
Do partial read in MemoryLeakTrackUtil dumpMemoryAddresses to avoid using more memory than what is allocated. Change-Id: I94feb4e00647407f938571167b981c7371f39e3d
Diffstat (limited to 'media/libmedia')
-rw-r--r--media/libmedia/MemoryLeakTrackUtil.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/media/libmedia/MemoryLeakTrackUtil.cpp b/media/libmedia/MemoryLeakTrackUtil.cpp
index 6a108ae..f004ca4 100644
--- a/media/libmedia/MemoryLeakTrackUtil.cpp
+++ b/media/libmedia/MemoryLeakTrackUtil.cpp
@@ -49,7 +49,7 @@ struct MyString8 {
}
void append(const char *s) {
- strcat(mPtr, s);
+ strncat(mPtr, s, MAX_SIZE - size() - 1);
}
const char *string() const {
@@ -60,6 +60,10 @@ struct MyString8 {
return strlen(mPtr);
}
+ void clear() {
+ *mPtr = '\0';
+ }
+
private:
char *mPtr;
@@ -139,6 +143,9 @@ void dumpMemoryAddresses(int fd)
}
} while (moved);
+ write(fd, result.string(), result.size());
+ result.clear();
+
for (size_t i = 0; i < count; i++) {
AllocEntry *e = &entries[i];
@@ -152,13 +159,14 @@ void dumpMemoryAddresses(int fd)
result.append(buffer);
}
result.append("\n");
+
+ write(fd, result.string(), result.size());
+ result.clear();
}
delete[] entries;
free_malloc_leak_info(info);
}
-
- write(fd, result.string(), result.size());
}
#else