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

Commit

Permalink
chakrashim: ensure chakra_shim_native buffer is null terminated
Browse files Browse the repository at this point in the history
PR-URL: #35
Reviewed-By: Jianchun Xu <Jianchun.Xu@microsoft.com>
  • Loading branch information
agarwal-sandeep committed Mar 9, 2016
1 parent adfadcc commit 75ace7d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions deps/chakrashim/src/jsrtcontextshim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,18 @@ bool ContextShim::ExposeGc() {
}

bool ContextShim::ExecuteChakraShimJS() {
wchar_t buffer[_countof(chakra_shim_native)];
wchar_t buffer[_countof(chakra_shim_native) + 1];

if (StringConvert::CopyRaw<char, wchar_t>(chakra_shim_native,
if (StringConvert::CopyRaw<unsigned char, wchar_t>(chakra_shim_native,
_countof(chakra_shim_native),
buffer,
_countof(chakra_shim_native)) != JsNoError) {
return false;
}

// Ensure the buffer is null terminated
buffer[_countof(chakra_shim_native)] = L'\0';

JsValueRef getInitFunction;
if (JsParseScript(buffer,
JS_SOURCE_CONTEXT_NONE,
Expand Down

0 comments on commit 75ace7d

Please sign in to comment.