From a2a302d8aadc1afdae0c13c23144a5acf9d2a8b0 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Wed, 21 Feb 2024 10:44:54 +0200 Subject: [PATCH] main-grpc: Fix iterator going invalid at destruction time Apparently, erase() would make the iterator invalid so we need grab the next one to have the work correctly. Bug-AGL: SPEC-5077 Signed-off-by: Marius Vlad Change-Id: I290fa1231eb6b37ab63c5f5c0bd8fe90d4363a77 --- grpc-proxy/main-grpc.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/grpc-proxy/main-grpc.cpp b/grpc-proxy/main-grpc.cpp index 92d4862..db33032 100644 --- a/grpc-proxy/main-grpc.cpp +++ b/grpc-proxy/main-grpc.cpp @@ -272,9 +272,8 @@ global_remove(void *data, struct wl_registry *reg, uint32_t id) (void) id; for (std::list::iterator it = sh->globals.begin(); - it != sh->globals.end(); it++) { - sh->globals.erase(it); - } + it != sh->globals.end(); it = sh->globals.erase(it)) + ; } static const struct wl_registry_listener registry_listener = { @@ -395,9 +394,8 @@ destroy_shell_data(struct shell_data *sh) destroy_output(w_output); for (std::list::iterator it = sh->globals.begin(); - it != sh->globals.end(); it++) { - sh->globals.erase(it); - } + it != sh->globals.end(); it = sh->globals.erase(it)) + ; wl_display_flush(sh->wl_display); wl_display_disconnect(sh->wl_display); -- 2.16.6