diff options
Diffstat (limited to 'media/libmedia')
-rw-r--r-- | media/libmedia/AudioParameter.cpp | 5 | ||||
-rw-r--r-- | media/libmedia/MemoryLeakTrackUtil.cpp | 14 |
2 files changed, 14 insertions, 5 deletions
diff --git a/media/libmedia/AudioParameter.cpp b/media/libmedia/AudioParameter.cpp index e3fea77..33dbf0b 100644 --- a/media/libmedia/AudioParameter.cpp +++ b/media/libmedia/AudioParameter.cpp @@ -37,9 +37,10 @@ AudioParameter::AudioParameter(const String8& keyValuePairs) { char *str = new char[keyValuePairs.length()+1]; mKeyValuePairs = keyValuePairs; + char *last; strcpy(str, keyValuePairs.string()); - char *pair = strtok(str, ";"); + char *pair = strtok_r(str, ";", &last); while (pair != NULL) { if (strlen(pair) != 0) { size_t eqIdx = strcspn(pair, "="); @@ -58,7 +59,7 @@ AudioParameter::AudioParameter(const String8& keyValuePairs) } else { ALOGV("AudioParameter() cstor empty key value pair"); } - pair = strtok(NULL, ";"); + pair = strtok_r(NULL, ";", &last); } delete[] str; 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 |