diff --git a/xwords4/wasm/main.c b/xwords4/wasm/main.c index 4edd59f52..32f3676d7 100644 --- a/xwords4/wasm/main.c +++ b/xwords4/wasm/main.c @@ -528,9 +528,21 @@ cleanupGame( GameState* gs ) static void deleteGame( GameState* gs ) { + Globals* globals = gs->globals; int gameID = gs->gi.gameID; /* remember it */ cleanupGame( gs ); + // Remove from linked list, but don't actually free because could live in + // a js-side object still. Needs refcounting or somesuch + GameState** prev = &globals->games; + for ( GameState* cur = globals->games; !!cur; cur = cur->next ) { + if ( gs == cur ) { + *prev = cur->next; + break; + } + prev = &cur->next; + } + char key[32]; formatNameKey( key, sizeof(key), gameID ); remove_stored_value( key );