Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
[Merge chakra-core/ChakraCore@55a0eb1825] [MERGE #3432 @MSLaguana] Fi…
Browse files Browse the repository at this point in the history
…xing debug assert failure in WriteStringCopy

Merge pull request #3432 from MSLaguana:fixStringCopyErrorChecking

The WriteStringCopy function was accessing string pointers without
setting up error handling correctly, triggering asserts in debug
builds.
  • Loading branch information
chakrabot committed Jul 27, 2017
1 parent 6dd968e commit fceec74
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions deps/chakrashim/core/lib/Jsrt/Jsrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4194,15 +4194,14 @@ JsErrorCode WriteStringCopy(
*written = 0; // init to 0 for default
}

if (!Js::JavascriptString::Is(value))
const char16* str = nullptr;
size_t strLength = 0;
JsErrorCode errorCode = JsStringToPointer(value, &str, &strLength);
if (errorCode != JsNoError)
{
return JsErrorInvalidArgument;
return errorCode;
}

Js::JavascriptString *jsString = Js::JavascriptString::FromVar(value);
const char16* str = jsString->GetSz();
size_t strLength = jsString->GetLength();

if (start < 0 || (size_t)start > strLength)
{
return JsErrorInvalidArgument; // start out of range, no chars written
Expand All @@ -4214,7 +4213,7 @@ JsErrorCode WriteStringCopy(
return JsNoError; // no chars written
}

JsErrorCode errorCode = copyFunc(str + start, count, written);
errorCode = copyFunc(str + start, count, written);
if (errorCode != JsNoError)
{
return errorCode;
Expand Down

0 comments on commit fceec74

Please sign in to comment.