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.
pull/60/head
nirenjan 2026-03-08 23:10:52 -07:00
parent b3dff7182b
commit f51b777ca0
2 changed files with 5 additions and 1 deletions

View File

@ -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 \

View File

@ -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);