From 2f9e7be04bf493d6a5737c0782e4033fbc5261da Mon Sep 17 00:00:00 2001 From: Mike Armstrong Date: Mon, 16 Nov 2015 09:33:59 -0800 Subject: [PATCH] fix output leaving bad characters in systrace output buffer due to overstepping bytes written Differential Revision: D2658628 fb-gh-sync-id: e4c9dc66746177d371331d79972f1322239b4ea7 --- ReactAndroid/src/main/jni/react/JSCTracing.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/jni/react/JSCTracing.cpp b/ReactAndroid/src/main/jni/react/JSCTracing.cpp index 59affe892..fa786005e 100644 --- a/ReactAndroid/src/main/jni/react/JSCTracing.cpp +++ b/ReactAndroid/src/main/jni/react/JSCTracing.cpp @@ -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(