From 5869484e213fc599992702d18561df04d296aff3 Mon Sep 17 00:00:00 2001 From: Michael Plante Date: Sat, 23 Jan 2010 18:28:50 -0600 Subject: r106: Fixed leak in usbi_alloc_device when pthread_mutex_init fails --- libusb/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libusb/core.c') 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; -- cgit v1.2.1