Make sure statistic file are initialized even if init is not called

This caused a NULL pointer dereference executing some tests
calling spice_server_destroy.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2016-11-17 09:19:17 +00:00
parent 973cbb4df2
commit e31c108417

View File

@ -3358,10 +3358,6 @@ static int do_spice_init(RedsState *reds, SpiceCoreInterface *core_interface)
spice_error("migration timer create failed");
}
#ifdef RED_STATISTICS
reds->stat_file = stat_file_new(REDS_MAX_STAT_NODES);
#endif
if (reds_init_net(reds) < 0) {
goto err;
}
@ -3437,6 +3433,9 @@ SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
reds->config->agent_copypaste = TRUE;
reds->config->agent_file_xfer = TRUE;
reds->config->exit_on_disconnect = FALSE;
#ifdef RED_STATISTICS
reds->stat_file = stat_file_new(REDS_MAX_STAT_NODES);
#endif
return reds;
}