From a1fdc07f34ef4788b24c7be3c3fb41a402409662 Mon Sep 17 00:00:00 2001 From: yhirose Date: Wed, 6 May 2026 08:36:38 -0400 Subject: [PATCH] Guard nullptr res in KeepAliveTest proxy template (#2443) 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. --- test/test_proxy.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_proxy.cc b/test/test_proxy.cc index 0cfb489..54198f5 100644 --- a/test/test_proxy.cc +++ b/test/test_proxy.cc @@ -291,10 +291,12 @@ template void KeepAliveTest(T &cli, bool basic) { { auto res = cli.Get("/get"); + ASSERT_TRUE(res != nullptr); EXPECT_EQ(StatusCode::OK_200, res->status); } { auto res = cli.Get("/redirect/2"); + ASSERT_TRUE(res != nullptr); EXPECT_EQ(StatusCode::OK_200, res->status); } @@ -306,6 +308,7 @@ template void KeepAliveTest(T &cli, bool basic) { for (auto path : paths) { auto res = cli.Get(path.c_str()); + ASSERT_TRUE(res != nullptr); auto body = normalizeJson(res->body); EXPECT_TRUE(body.find("\"authenticated\":true") != std::string::npos); EXPECT_TRUE(body.find("\"user\":\"hello\"") != std::string::npos); @@ -317,6 +320,7 @@ template void KeepAliveTest(T &cli, bool basic) { int count = 10; while (count--) { auto res = cli.Get("/get"); + ASSERT_TRUE(res != nullptr); EXPECT_EQ(StatusCode::OK_200, res->status); } }