Skip to content

Commit ce368e7

Browse files
committed
[MERGE chakra-core#882] Fixing the static warning by adding sufficient validation for the buffer.
Merge pull request chakra-core#882 from akroshg:warn
2 parents f7a6615 + f0ac7c7 commit ce368e7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/Runtime/Library/JavascriptString.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2399,7 +2399,7 @@ namespace Js
23992399
Assert(count > 0);
24002400

24012401
const char16* currentRawString = currentString->GetString();
2402-
int currentLength = currentString->GetLength();
2402+
charcount_t currentLength = currentString->GetLength();
24032403

24042404
charcount_t finalBufferCount = UInt32Math::Add(UInt32Math::Mul(count, currentLength), 1);
24052405
char16* buffer = RecyclerNewArrayLeaf(scriptContext->GetRecycler(), char16, finalBufferCount);
@@ -2413,6 +2413,7 @@ namespace Js
24132413
{
24142414
char16* bufferDst = buffer;
24152415
size_t bufferDstSize = finalBufferCount;
2416+
AnalysisAssert(bufferDstSize > currentLength);
24162417

24172418
for (charcount_t i = 0; i < count; i += 1)
24182419
{

0 commit comments

Comments
 (0)