Skip to content

Commit

Permalink
Avoid MSVC iterator debugging assertion
Browse files Browse the repository at this point in the history
Summary:
When compiling with MSVC STL headers and iterator debugging enabled
(a common case for debug builds), attempting to dereference
std::string::end() leads to a failing assertion.

To avoid this, we can just use the data pointer and string size to
fetch the begin and end addressed of the string.

Reviewed By: neildhar

Differential Revision: D66009100

fbshipit-source-id: cac2b796be4973db6811b08a2e696c8df7ec85d6
  • Loading branch information
rozele authored and facebook-github-bot committed Nov 15, 2024
1 parent 5cd8e44 commit 47d8c7f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/VM/JSError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,8 @@ void JSError::appendBytecodeFrame(
location->filenameId);
convertUTF8WithSurrogatesToUTF16(
std::back_inserter(stack),
&*utf8Filename.begin(),
&*utf8Filename.end());
utf8Filename.data(),
utf8Filename.data() + utf8Filename.size());
} else {
auto sourceURL = runtimeModule->getSourceURL();
stack.append(sourceURL.empty() ? "unknown" : sourceURL);
Expand Down

0 comments on commit 47d8c7f

Please sign in to comment.