From 00cbc1ab87281dd4f5cca9c95494482a3d03a665 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Tue, 27 Feb 2024 11:28:49 +0100 Subject: [PATCH] common: Set pointer to NULL after freeing them --- common/gattlib_callback_discovered_device.c | 1 + common/gattlib_callback_notification_device.c | 2 ++ common/gattlib_common.c | 1 + 3 files changed, 4 insertions(+) diff --git a/common/gattlib_callback_discovered_device.c b/common/gattlib_callback_discovered_device.c index b32f20ea..4a13020d 100644 --- a/common/gattlib_callback_discovered_device.c +++ b/common/gattlib_callback_discovered_device.c @@ -62,6 +62,7 @@ static gpointer _gattlib_discovered_device_thread(gpointer data) { free(args->mac_address); if (args->name != NULL) { free(args->name); + args->name = NULL; } free(args); return NULL; diff --git a/common/gattlib_callback_notification_device.c b/common/gattlib_callback_notification_device.c index 771e5076..89daf6cf 100644 --- a/common/gattlib_callback_notification_device.c +++ b/common/gattlib_callback_notification_device.c @@ -61,9 +61,11 @@ void gattlib_notification_device_thread(gpointer data, gpointer user_data) { if (args->uuid != NULL) { free(args->uuid); + args->uuid = NULL; } if (args->data != NULL) { free(args->data); + args->data = NULL; } } diff --git a/common/gattlib_common.c b/common/gattlib_common.c index b0bfcfe0..eed1a775 100644 --- a/common/gattlib_common.c +++ b/common/gattlib_common.c @@ -151,6 +151,7 @@ void gattlib_handler_free(struct gattlib_handler* handler) { Py_DECREF(args->args); handler->python_args = NULL; free(handler->python_args); + handler->python_args = NULL; } if (handler->thread_pool != NULL) {