emilk / loguru

A lightweight C++ logging library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

home_dir() fatal error on _win32 when using ~ in log file path

mercurysky opened this issue · comments

Within the home_dir() function, the assertion CHECK_F has the incorrect logic for the return value of _dupenv_s on windows. It currently is asserting failure when errno_t is zero, which is not an error.

From documentation for _dupenv "Zero on success, an error code on failure"

I confirmed this in the debugger using MSVC2019 when a log file is provided of the form "~/mylogfile.log".

errno_t err = _dupenv_s(&user_profile, &len, "USERPROFILE");

Current

CHECK_F(err != 0, "Missing USERPROFILE");

Needed fix

CHECK_F(err == 0, "Missing USERPROFILE");