Skip to content

Guard nullptr res in KeepAliveTest proxy template#2443

Merged
yhirose merged 1 commit into
masterfrom
fix/proxy-test-nullptr-guard
May 6, 2026
Merged

Guard nullptr res in KeepAliveTest proxy template#2443
yhirose merged 1 commit into
masterfrom
fix/proxy-test-nullptr-guard

Conversation

@yhirose
Copy link
Copy Markdown
Owner

@yhirose yhirose commented May 6, 2026

Summary

KeepAliveTest (template in test/test_proxy.cc) calls cli.Get(...) and immediately dereferences res without a nullptr check. When the upstream request to httpbingo.org transiently fails (network blip / proxy hiccup), res is nullptr and the next line crashes the test process with a SEGV inside std::__cxx11::basic_string<...>::begin() under ASan, taking the whole proxy test job down.

Observed in https://github.com/yhirose/cpp-httplib/actions/runs/25435118501/job/74610932675 — the same source SHA had passed proxy tests on the PR run minutes earlier, confirming flakiness rather than a real regression.

Add ASSERT_TRUE(res != nullptr); to the four Get() call sites inside the KeepAliveTest template. The sibling templates in the same file (ProxyTest, line 19) already use this pattern.

Test plan

  • CI: proxy (openssl) job passes
  • CI: proxy (mbedtls) job passes

When the upstream request to httpbingo.org transiently fails, cli.Get()
returns nullptr and the next line dereferences it (res->status / res->body),
producing a SEGV in std::string::begin() under ASan. Sibling templates in
the same file already use ASSERT_TRUE(res != nullptr); apply the same
guard to the four Get() call sites in KeepAliveTest so a flaky network
turns into a clean test failure instead of a crash.
@yhirose yhirose merged commit a1fdc07 into master May 6, 2026
36 of 37 checks passed
@yhirose yhirose deleted the fix/proxy-test-nullptr-guard branch May 6, 2026 12:36
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