From 7c231568aaa77f0a516806cf43d09ab64a028f21 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Mon, 25 Jan 2021 18:49:21 -0600 Subject: [PATCH] cdba-server: Don't close what wasn't opened In the case that we quit without actually having opened a device this would dereference a NULL pointer, so check the device before doing so. Signed-off-by: Bjorn Andersson --- cdba-server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdba-server.c b/cdba-server.c index 94653fa..bc0f5da 100644 --- a/cdba-server.c +++ b/cdba-server.c @@ -413,7 +413,8 @@ int main(int argc, char **argv) done: - device_close(selected_device); + if (selected_device) + device_close(selected_device); return 0; }