Skip to content

Fix off-by-one error for strings of certain sizes#47

Merged
jasongin merged 1 commit intonodejs:masterfrom
jasongin:fix-strings
May 25, 2017
Merged

Fix off-by-one error for strings of certain sizes#47
jasongin merged 1 commit intonodejs:masterfrom
jasongin:fix-strings

Conversation

@jasongin
Copy link
Copy Markdown
Member

Resizing a std::string to the number of chars to be copied into it usually worked because of how std::string usually allocates a little more memory than what is requested. But sometimes there would be no extra capacity, so the capacity() value passed to napi_get_value_string() was too short by one (due to the null-terminator). The result was strings of certain lengths could have one char trimmed off the end.

Resizing a std::string to the number of chars to be copied into it usually worked because of how std::string usually allocates a little more memory than what is requested. But sometimes there would be no extra capacity, so the capacity() value passed to napi_get_value_string() was too short by one (due to the null-terminator). The result was strings of certain lengths could have one char trimmed off the end.
@jasongin jasongin requested review from addaleax and boingoing May 23, 2017 00:08
Copy link
Copy Markdown
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown

@boingoing boingoing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jasongin jasongin merged commit d8b50de into nodejs:master May 25, 2017
@jasongin jasongin deleted the fix-strings branch May 25, 2017 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants