test on pointer before set to NULL

This commit is contained in:
Théophyl Hoguet committed 2021-12-07 15:49:12 +01:00
1 parent 7b42e41b19
commit 3efa272882
1 file changed
+6 -3
+6 -3
View File
@@ -64,12 +64,15 @@ bool game_equal(cgame g1, cgame g2) {
void game_delete(game g) {
for (int i = 0; i < DEFAULT_SIZE; i++) {
free(g->tab_cell[i]);
g->tab_cell[i] = NULL;
if (g->tab_cell[i] != NULL)
g->tab_cell[i] = NULL;
}
free(g->tab_cell);
g->tab_cell = NULL;
if (g->tab_cell != NULL)
g->tab_cell = NULL;
free(g);
g = NULL;
if (g != NULL)
g = NULL;
return;
}