Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2a46dc7

Browse filesBrowse files
zcbenztargos
authored andcommitted
src: check empty before accessing string
Fix an assertion when running dotnev tests with GN build: assertion !empty() failed: string::front(): string is empty which was caused by calling value.front() without verifying the value is not empty. PR-URL: #51665 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent ba444a9 commit 2a46dc7
Copy full SHA for 2a46dc7

File tree

Expand file treeCollapse file tree

1 file changed

+4
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-4
lines changed
Open diff view settings
Collapse file

‎src/node_dotenv.cc‎

Copy file name to clipboardExpand all lines: src/node_dotenv.cc
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ void Dotenv::ParseContent(const std::string_view content) {
116116
value.erase(0, value.find_first_not_of(" \t"));
117117

118118
// Remove trailing whitespaces
119-
value.erase(value.find_last_not_of(" \t") + 1);
120-
121-
const char maybeQuote = value.front();
119+
if (!value.empty()) {
120+
value.erase(value.find_last_not_of(" \t") + 1);
121+
}
122122

123-
if (maybeQuote == '"') {
123+
if (!value.empty() && value.front() == '"') {
124124
value = std::regex_replace(value, std::regex("\\\\n"), "\n");
125125
value = std::regex_replace(value, std::regex("\\\\r"), "\r");
126126
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.