Stop potential lockup due to GHashTable being modified when cleared. (flutter/engine#22917)

This doesn't seem to be currently occuring, but I triggered such a lockup
when modifying other code.
This commit is contained in:
Robert Ancell
2020-12-09 07:26:35 +13:00
committed by GitHub
parent f76ed3c254
commit 516165af02

View File

@@ -106,7 +106,11 @@ static void engine_weak_notify_cb(gpointer user_data,
self->engine = nullptr;
// Disconnect any handlers.
g_hash_table_remove_all(self->platform_message_handlers);
// Take the reference in case a handler tries to modify this table.
g_autoptr(GHashTable) handlers = self->platform_message_handlers;
self->platform_message_handlers = g_hash_table_new_full(
g_str_hash, g_str_equal, g_free, platform_message_handler_free);
g_hash_table_remove_all(handlers);
}
static gboolean fl_binary_messenger_platform_message_cb(