Skip to content

Commit

Permalink
fix: off by one get_var msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Aug 22, 2024
1 parent 39dad10 commit 4ca5168
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion share/cpp2b.cppm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ inline auto set_var(auto name, auto value) -> void {
inline auto get_var(const std::string& name) -> std::optional<std::string> {
#if defined(_MSC_VER)
auto val = std::string{""};
val.resize(GetEnvironmentVariableA(name.c_str(), val.data(), 1) - 1);
val.resize(GetEnvironmentVariableA(name.c_str(), val.data(), 1));

if(!val.empty()) {
GetEnvironmentVariableA(name.c_str(), val.data(), val.size() + 1);
Expand Down

0 comments on commit 4ca5168

Please sign in to comment.