From f51b777ca03ad74164f27e81e277ddb317a45c5f Mon Sep 17 00:00:00 2001 From: nirenjan Date: Sun, 8 Mar 2026 23:10:52 -0700 Subject: [PATCH] fix: Handle NULL pointer dereferencing in libx52 libx52_exit dereferences the device pointer to deinitialize libusb. However, a user could pass NULL to this function, resulting in a null pointer dereference. --- libx52/Makefile.am | 2 +- libx52/x52_core.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libx52/Makefile.am b/libx52/Makefile.am index a3cda40..84b4619 100644 --- a/libx52/Makefile.am +++ b/libx52/Makefile.am @@ -12,7 +12,7 @@ lib_LTLIBRARIES += libx52.la # See: https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html libx52_v_CUR=6 libx52_v_AGE=4 -libx52_v_REV=1 +libx52_v_REV=2 libx52_la_SOURCES = \ libx52/x52_control.c \ libx52/x52_core.c \ diff --git a/libx52/x52_core.c b/libx52/x52_core.c index 7f730d8..47410bc 100644 --- a/libx52/x52_core.c +++ b/libx52/x52_core.c @@ -229,6 +229,10 @@ int libx52_init(libx52_device **dev) void libx52_exit(libx52_device *dev) { + if (!dev) { + return; + } + libx52_disconnect(dev); libusb_exit(dev->ctx);