From c7b1ac57d8f8374a4b3a7e8c0f7c2b06417f2026 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 9 Dec 2021 00:46:18 +0800 Subject: [PATCH] locationd_thread: fix possible dangling reference to params (#23156) old-commit-hash: 48963d4b24223aa7e87f257558bf7caa48761868 --- selfdrive/locationd/locationd.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index 8e8641e7d5..7926846895 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -497,8 +497,6 @@ int Localizer::locationd_thread() { PubMaster pm({ "liveLocationKalman" }); SubMaster sm(service_list, nullptr, { "gpsLocationExternal" }); - Params params; - while (!do_exit) { sm.update(); for (const char* service : service_list) { @@ -523,8 +521,8 @@ int Localizer::locationd_thread() { std::string lastGPSPosJSON = util::string_format( "{\"latitude\": %.15f, \"longitude\": %.15f, \"altitude\": %.15f}", posGeo(0), posGeo(1), posGeo(2)); - std::thread([¶ms] (const std::string gpsjson) { - params.put("LastGPSPosition", gpsjson); + std::thread([] (const std::string gpsjson) { + Params().put("LastGPSPosition", gpsjson); }, lastGPSPosJSON).detach(); } }