cpp-netlib/uri

Crash when clearing query parameters using network::uri::uri_builder if no parameters exist in original URI

Closed this issue · 1 comments

zsims commented

When clearing query parameters using the URI builder, a debug assertion (from SCL) is tripped if the original URI doesn't have query strings.

clear_query
network::uri original("http://example.com/path");
network::uri_builder builder(original);
builder.clear_query(); // BOOM

Note that this doesn't crash if original had a query string. Details:

Debug Assertion Failed!

Program: ...path\to\program.exe
File: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xmemory0
Line: 100

Expression: "(_Ptr_user & (_BIG_ALLOCATION_ALIGNMENT - 1)) == 0" && 0

Stack trace:

program.exe!std::_Deallocate(void * _Ptr, unsigned __int64 _Count, unsigned __int64 _Sz) Line 99	C++
program.exe!std::allocator<char>::deallocate(char * _Ptr, unsigned __int64 _Count) Line 721	C++
program.exe!std::_Wrap_alloc<std::allocator<char> >::deallocate(char * _Ptr, unsigned __int64 _Count) Line 988	C++
program.exe!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Tidy(bool _Built, unsigned __int64 _Newsize) Line 2260	C++
program.exe!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >() Line 1017	C++
program.exe!network::optional<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >::operator=(network::nullopt_t __formal) Line 241	C++
program.exe!network::uri_builder::clear_query() Line 127	C++

Compiler is VC++ 2015.

zsims commented

Thanks for fixing this, and the awesome library 😀