diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2024-02-21 10:44:54 +0200 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2024-02-23 18:08:16 +0200 |
commit | a2a302d8aadc1afdae0c13c23144a5acf9d2a8b0 (patch) | |
tree | 5b6bd219ba703cdb3b80710090402c5df7a9cc94 | |
parent | e7ccf51adc37748d3ca000109d16d0495dc0a7e8 (diff) |
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 <marius.vlad@collabora.com>
Change-Id: I290fa1231eb6b37ab63c5f5c0bd8fe90d4363a77
-rw-r--r-- | grpc-proxy/main-grpc.cpp | 10 |
1 files 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<global_data>::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<global_data>::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); |