Skip to content

Fix HTTP address-resolution diagnostics on Unicode Windows builds - #9569

Draft
salehqt wants to merge 1 commit into
Exiv2:mainfrom
salehqt:fix-windows-gai-strerror
Draft

salehqt wants to merge 1 commit into
Exiv2:mainfrom
salehqt:fix-windows-gai-strerror

Conversation

@salehqt

@salehqt salehqt commented Nov 17, 2026

Copy link
Copy Markdown

Summary

When UNICODE is defined on Windows, gai_strerror resolves to
gai_strerrorW, which returns WCHAR*. Passing that result to the HTTP
error-reporting function, which takes const char*, does not compile.

Add a file-local helper that converts the Windows error text to UTF-8 and
returns the existing narrow error text on other platforms. Use the helper
at the getaddrinfo failure call site.

The Windows conversion checks both sizing and conversion failures,
allocates room for the terminating NUL, and removes that terminator from
the returned string. It needs no additional Windows header or macro
definition.

Add a unit test for the HTTP address-resolution error path using a
loopback address and an invalid service name. It does not require an
external HTTP server and is enabled only in webready builds.

Testing

  • macOS arm64 Release build using the upstream base_mac preset, including
    webready support, samples, unit tests, and warnings-as-errors: passed.
  • ctest --test-dir build-pr --output-on-failure: all 8 test suites passed.
  • http.reportsAddressResolutionError: passed when run separately.
  • clang-format --dry-run --Werror on the changed files and git diff --check:
    passed.

Native Windows/MSVC validation with UNICODE remains to be run; the Mac
build does not execute the Windows conversion branch.

Convert gai_strerrorW diagnostics to UTF-8 before passing them to the narrow HTTP error-reporting function. Guard both conversion calls and allocate space for the terminating NUL. Preserve gai_strerror on other platforms.

Exercise the address-resolution error path with a loopback address and invalid service name in webready unit tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant