# HG changeset patch # User David Demelier # Date 1540989805 -3600 # Node ID 1b17b2af5a6b418494eceea68a9276ff8d2c78d6 # Parent 27a6cbb188970648340fd2ef061c23c494159ebc Plugin links: add query and fix use-after-free diff -r 27a6cbb18897 -r 1b17b2af5a6b plugins/links/uri.cpp --- a/plugins/links/uri.cpp Tue Oct 30 13:45:55 2018 +0100 +++ b/plugins/links/uri.cpp Wed Oct 31 13:43:25 2018 +0100 @@ -48,11 +48,12 @@ UriParserStateA state; UriUriA hnd; uri ret; + string copy = match[1].str(); scope_exit exit([&hnd] { uriFreeUriMembersA(&hnd); }); state.uri = &hnd; - if (uriParseUriA(&state, match[1].str().c_str()) != URI_SUCCESS) + if (uriParseUriA(&state, copy.c_str()) != URI_SUCCESS) return nullopt; if (hnd.scheme.first) @@ -80,6 +81,12 @@ if (ret.path.empty()) ret.path = "/"; + // Add query if needed. + if (hnd.query.first) { + ret.path += "?"; + ret.path += string(hnd.query.first, hnd.query.afterLast - hnd.query.first); + } + return ret; }