mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-11 22:32:38 +08:00
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:
committed by
facebook-github-bot-4
parent
b7f5062128
commit
2f9e7be04b
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user