From 2dc752e0744a940d39740147da38d6ca59f28981 Mon Sep 17 00:00:00 2001 From: PurpleCloudX Date: Mon, 25 Nov 2024 22:43:58 +0800 Subject: [PATCH] Fix potential null pointer dereference in bmx280_close --- bmx280.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bmx280.c b/bmx280.c index 240c7fa..ba29c94 100644 --- a/bmx280.c +++ b/bmx280.c @@ -451,7 +451,7 @@ bmx280_t* bmx280_create_master(i2c_master_bus_handle_t bus_handle) void bmx280_close(bmx280_t *bmx280) { #if CONFIG_USE_I2C_MASTER_DRIVER - if(bmx280->i2c_dev!=NULL) + if(bmx280 != NULL && bmx280->i2c_dev != NULL) i2c_master_bus_rm_device(bmx280->i2c_dev); #endif free(bmx280);