-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Correcting memory allocation in LiteralStringWithPropertyStringPtr::NewFromCString #4641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correcting memory allocation in LiteralStringWithPropertyStringPtr::NewFromCString #4641
Conversation
Could you please point out the change that is justifying the description above? |
|
Found it; Good catch. |
|
CI errors are related to type casting. LGTM |
|
Ah yep, I see that I missed some usages in wabt when I tweaked the templating. I'll get that fixed tomorrow. |
sethbrenith
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch!
lib/Runtime/Library/ConcatString.cpp
Outdated
| ScriptContext * scriptContext = library->GetScriptContext(); | ||
| size_t cbDestString = (charCount + 1) * sizeof(WCHAR); | ||
| if ((CharCount)cbDestString < charCount) // overflow | ||
| if (charCount > MaxCharCount) // overflow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"overflow" comment might be out of date; I think it was referring to arithmetic overflow when computing (charCount + 1) * sizeof(WCHAR)
…ewFromCString A confusion between bytes and character count meant that JsCreateString was creating strings that used twice as much space as they needed.
652a2ff to
1492900
Compare
…gWithPropertyStringPtr::NewFromCString Merge pull request #4641 from MSLaguana:fixJsrtStringCreation A confusion between bytes and character count meant that JsCreateString was creating strings that used twice as much space as they needed. While I was at it, I also tried to clean up the types in `Utf8Helper.h` to make it more clear what the values referred to.
|
Thanks for the reviews! |
… LiteralStringWithPropertyStringPtr::NewFromCString Merge pull request #4641 from MSLaguana:fixJsrtStringCreation A confusion between bytes and character count meant that JsCreateString was creating strings that used twice as much space as they needed. While I was at it, I also tried to clean up the types in `Utf8Helper.h` to make it more clear what the values referred to.
A confusion between bytes and character count meant that JsCreateString
was creating strings that used twice as much space as they needed.
While I was at it, I also tried to clean up the types in
Utf8Helper.hto make it more clear what the values referred to.