From 60a3298c2ec12ab988e71c05f8cb152fca2caa7d Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 5 Oct 2019 11:28:17 +0200 Subject: [PATCH] Make DEVNUM robust against double initialization. --- src/spicelib/devices/dev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/spicelib/devices/dev.c b/src/spicelib/devices/dev.c index 6d9b9217f..1298eb016 100644 --- a/src/spicelib/devices/dev.c +++ b/src/spicelib/devices/dev.c @@ -244,6 +244,7 @@ spice_destroy_devices(void) tfree(DEVicesfl); #endif tfree(DEVices); + DEVNUM = 0; } @@ -251,9 +252,11 @@ void spice_init_devices(void) { int i; + /* Safeguard against double initialization */ + DEVNUM = NUMELEMS(static_devices); #ifdef XSPICE - /*Initilise the structs and add digital node type */ + /* Initialize the structs and add digital node type */ g_evt_udn_info = TMALLOC(Evt_Udn_Info_t *, 1); g_evt_num_udn_types = 1; g_evt_udn_info[0] = &idn_digital_info;