summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libusb/core.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libusb/core.c b/libusb/core.c
index 6adf67e..7455bbb 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -521,8 +521,10 @@ struct libusb_device *usbi_alloc_device(struct libusb_context *ctx,
return NULL;
r = pthread_mutex_init(&dev->lock, NULL);
- if (r)
+ if (r) {
+ free(dev);
return NULL;
+ }
dev->ctx = ctx;
dev->refcnt = 1;