fix null terminated string parsing

bug: 63633199
Change-Id: I443d8799281d22d02e25df844739ef6c376ef9e2
diff --git a/media/extractors/mp4/ItemTable.cpp b/media/extractors/mp4/ItemTable.cpp
index cef5f4a..74d5f1f 100644
--- a/media/extractors/mp4/ItemTable.cpp
+++ b/media/extractors/mp4/ItemTable.cpp
@@ -982,26 +982,24 @@
 
 bool InfeBox::parseNullTerminatedString(
         off64_t *offset, size_t *size, String8 *out) {
-    char tmp[256];
-    size_t len = 0;
+    char tmp;
+    Vector<char> buf;
+    buf.setCapacity(256);
     off64_t newOffset = *offset;
     off64_t stopOffset = *offset + *size;
     while (newOffset < stopOffset) {
-        if (!source()->readAt(newOffset++, &tmp[len], 1)) {
+        if (!source()->readAt(newOffset++, &tmp, 1)) {
             return false;
         }
-        if (tmp[len] == 0) {
-            out->append(tmp, len);
+        buf.push_back(tmp);
+        if (tmp == 0) {
+            out->setTo(buf.array());
 
             *offset = newOffset;
             *size = stopOffset - newOffset;
 
             return true;
         }
-        if (++len >= sizeof(tmp)) {
-            out->append(tmp, len);
-            len = 0;
-        }
     }
     return false;
 }