From 44a6e7c1b4e698ed2713b88833e961adb3029a03 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 25 May 2024 02:02:55 +0200 Subject: [PATCH] Device: Do not free init_dev if points to dev, fixes SIGTRAP. --- src/device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/device.c b/src/device.c index 24042b83a..8517045e2 100644 --- a/src/device.c +++ b/src/device.c @@ -137,8 +137,8 @@ device_context_restore(void) static void * device_add_common(const device_t *dev, void *p, void *params, int inst) { - device_t *init_dev; - void *priv = NULL; + device_t *init_dev = NULL; + void *priv = NULL; int c; if (params != NULL) { @@ -204,7 +204,8 @@ device_add_common(const device_t *dev, void *p, void *params, int inst) } else device_priv[c] = p; - free(init_dev); + if (init_dev != dev) + free(init_dev); return priv; }