fix: address fopen() patch followups in main.c#351
Merged
spe-ciellt merged 1 commit intogerbv:developfrom Mar 5, 2026
Merged
Conversation
1. Replace raw fopen() with g_fopen() for --log file, so non-ASCII paths work on Windows after the argv UTF-8 conversion. 2. The #include <glib/gstdio.h> already present in main.c is now justified by the g_fopen() call above. 3. Change #ifdef G_OS_WIN32 to #ifdef WIN32 to match the existing style used throughout main.c. 4. Add a comment explaining the intentional argv pointer leak from the codepage conversion — the converted strings must outlive main() and this block only runs on Windows, invisible to Linux Valgrind. 5. Preserve errno from g_fopen() failure and include strerror() in the error message. Closes gerbv#349
This was referenced Mar 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses all four items from #349:
1.
logToFileFilenamenow usesg_fopen()The
--logfile was still opened with rawfopen(), which fails silently on Windows for non-ASCII paths even after the argv UTF-8 conversion from #318. Switched tog_fopen()which handles UTF-8 paths correctly on all platforms.Also preserves
errnoand includesstrerror()in the error message for better diagnostics.2.
#include <glib/gstdio.h>is now justifiedThe include was added in #318 but wasn't actually needed at the time. With the
g_fopen()call above, it's now required.3.
#ifdef G_OS_WIN32→#ifdef WIN32Changed to match the existing style used consistently throughout
main.c(bind_textdomain_codeset,screenRenderInfo.renderType, etc.). Both macros resolve identically on Windows.4. Argv leak documented
Added a block comment explaining that the
g_locale_to_utf8()allocations intentionally replace the C runtime'sargv[i]pointers and are never freed — they must outlivemain(). The block only compiles on Windows, so it won't appear in Linux Valgrind runs.Closes #349