From d1121d174c2bb612ca8a07d601975c38ad98c399 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 10 Nov 2014 22:09:28 +0100 Subject: [PATCH] Fix a few memory leaks. --- src/suunto_eonsteel.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/suunto_eonsteel.c b/src/suunto_eonsteel.c index 1661fa6..ab090bf 100644 --- a/src/suunto_eonsteel.c +++ b/src/suunto_eonsteel.c @@ -501,6 +501,7 @@ suunto_eonsteel_device_open(dc_device_t **out, dc_context_t *context, const char if (libusb_init(&eon->ctx)) { ERROR(context, "libusb_init() failed"); + free(eon); return DC_STATUS_IO; } @@ -508,6 +509,7 @@ suunto_eonsteel_device_open(dc_device_t **out, dc_context_t *context, const char if (!eon->handle) { ERROR(context, "unable to open device"); libusb_exit(eon->ctx); + free(eon); return DC_STATUS_IO; } @@ -519,7 +521,9 @@ suunto_eonsteel_device_open(dc_device_t **out, dc_context_t *context, const char if (initialize_eonsteel(eon) < 0) { ERROR(context, "unable to initialize device"); + libusb_close(eon->handle); libusb_exit(eon->ctx); + free(eon); return DC_STATUS_IO; }