fix output leaving bad characters in systrace output buffer due to overstepping bytes written

Differential Revision: D2658628

fb-gh-sync-id: e4c9dc66746177d371331d79972f1322239b4ea7
This commit is contained in:
Mike Armstrong 2015-11-16 09:33:59 -08:00 committed by facebook-github-bot-4
parent b7f5062128
commit 2f9e7be04b

View File

@ -42,6 +42,7 @@ static size_t copyTruncatedAsciiChars(
// rather than the beginning.
size_t toWrite = min(stringLen, min(bufLen, maxLen));
const char *startBuf = buf;
const JSChar* chars = JSStringGetCharactersPtr(jsString);
while (toWrite-- > 0) {
*(buf++) = (char)*(chars++);
@ -49,8 +50,8 @@ static size_t copyTruncatedAsciiChars(
JSStringRelease(jsString);
// Return the full length to match snprintf semantics.
return stringLen;
// Return the number of bytes written
return buf - startBuf;
}
static size_t copyArgsToBuffer(