From 243995f36f4ee40aa88c1d29b976b944a3d1ac74 Mon Sep 17 00:00:00 2001 From: Bryce Anderson Date: Thu, 30 Apr 2015 20:56:28 -0400 Subject: Fix memory error and invalid param when no params are present Also added a unit test that fails with the previous behavior. Note that `-fsanitize=address` exposes the invalid memory access in qs_parse. --- tests/unittest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/unittest.cpp b/tests/unittest.cpp index 460abac..e1c440b 100644 --- a/tests/unittest.cpp +++ b/tests/unittest.cpp @@ -1,6 +1,7 @@ //#define CROW_ENABLE_LOGGING #define CROW_ENABLE_DEBUG #include +#include #include #include "settings.h" #undef CROW_LOG_LEVEL @@ -943,6 +944,20 @@ TEST(simple_url_params) asio::io_service is; std::string sendmsg; + // check empty params + sendmsg = "GET /params\r\n\r\n"; + { + asio::ip::tcp::socket c(is); + c.connect(asio::ip::tcp::endpoint(asio::ip::address::from_string("127.0.0.1"), 45451)); + c.send(asio::buffer(sendmsg)); + c.receive(asio::buffer(buf, 2048)); + c.close(); + + stringstream ss; + ss << last_url_params; + + ASSERT_EQUAL("[ ]", ss.str()); + } // check single presence sendmsg = "GET /params?foobar\r\n\r\n"; { -- cgit v1.2.3-54-g00ecf