Skip to content

Commit

Permalink
common: Set pointer to NULL after freeing them
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviermartin committed Feb 27, 2024
1 parent d270205 commit 00cbc1a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/gattlib_callback_discovered_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions common/gattlib_callback_notification_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
1 change: 1 addition & 0 deletions common/gattlib_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 00cbc1a

Please sign in to comment.