UI/Qt: Prevent UAF while parsing autocomplete response data

JsonParser only holds a view into the provided string, the caller must
keep it alive. Though we can actually just use JsonValue::from_string
here instead.
This commit is contained in:
Timothy Flynn 2025-03-19 17:02:18 -04:00 committed by Jelle Raaijmakers
parent ea8213f7fa
commit 86a93b9b47
Notes: github-actions[bot] 2025-03-20 09:51:49 +00:00

View file

@ -6,7 +6,6 @@
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
#include <AK/JsonParser.h>
#include <LibURL/URL.h>
#include <UI/Qt/AutoComplete.h>
#include <UI/Qt/Settings.h>
@ -111,8 +110,8 @@ ErrorOr<void> AutoComplete::got_network_response(QNetworkReply* reply)
if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError)
return {};
AK::JsonParser parser(ak_byte_string_from_qstring(reply->readAll()));
auto json = TRY(parser.parse());
auto reply_data = ak_string_from_qstring(reply->readAll());
auto json = TRY(JsonValue::from_string(reply_data));
auto engine_name = Settings::the()->autocomplete_engine().name;
Vector<String> results;