From 743a6e634ef6509a990b3612d9806a9280a99725 Mon Sep 17 00:00:00 2001 From: Victor Gomes Date: Wed, 14 Feb 2024 13:43:08 +0100 Subject: [PATCH] src: fix empty string access in dotenv --- src/node_dotenv.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/node_dotenv.cc b/src/node_dotenv.cc index 53faf461bb42f2..e884b88c3f8449 100644 --- a/src/node_dotenv.cc +++ b/src/node_dotenv.cc @@ -118,9 +118,7 @@ void Dotenv::ParseContent(const std::string_view content) { // Remove trailing whitespaces value.erase(value.find_last_not_of(" \t") + 1); - const char maybeQuote = value.front(); - - if (maybeQuote == '"') { + if (!value.empty() && value.front() == '"') { value = std::regex_replace(value, std::regex("\\\\n"), "\n"); value = std::regex_replace(value, std::regex("\\\\r"), "\r"); }