Don't depend on String8 cast to C string
Bug: 295394788
Test: m checkbuild
Change-Id: I6aa039b6b2a4944e3537ef133f8785890d957edd
diff --git a/tools/aapt/StringPool.cpp b/tools/aapt/StringPool.cpp
index 8d02683..1af8d6f 100644
--- a/tools/aapt/StringPool.cpp
+++ b/tools/aapt/StringPool.cpp
@@ -472,13 +472,13 @@
ENCODE_LENGTH(strings, sizeof(uint8_t), encSize)
- strncpy((char*)strings, encStr, encSize+1);
+ strncpy((char*)strings, encStr.c_str(), encSize + 1);
} else {
char16_t* strings = (char16_t*)dat;
ENCODE_LENGTH(strings, sizeof(char16_t), strSize)
- strcpy16_htod(strings, ent.value);
+ strcpy16_htod(strings, ent.value.c_str());
}
strPos += totalSize;
@@ -592,7 +592,7 @@
ssize_t res = indices != NULL && indices->size() > 0 ? indices->itemAt(0) : -1;
if (kIsDebug) {
printf("Offset for string %s: %zd (%s)\n", String8(val).c_str(), res,
- res >= 0 ? String8(mEntries[mEntryArray[res]].value).c_str() : String8());
+ res >= 0 ? String8(mEntries[mEntryArray[res]].value).c_str() : "");
}
return res;
}