Guard nullptr res in KeepAliveTest proxy template#2443
Merged
Conversation
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.
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.
Summary
KeepAliveTest(template intest/test_proxy.cc) callscli.Get(...)and immediately dereferencesreswithout anullptrcheck. When the upstream request tohttpbingo.orgtransiently fails (network blip / proxy hiccup),resisnullptrand the next line crashes the test process with a SEGV insidestd::__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 fourGet()call sites inside theKeepAliveTesttemplate. The sibling templates in the same file (ProxyTest, line 19) already use this pattern.Test plan
proxy (openssl)job passesproxy (mbedtls)job passes