summaryrefslogtreecommitdiffstats
path: root/serial_ftdi.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-09-10 07:19:04 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-09 21:33:49 -0700
commit51ce83ed20cd2ea493cf8118c1d85f9963f4e77f (patch)
treeaae8caa68f72113145a244ea35ccfd4c6735a1fb /serial_ftdi.c
parent54eefe2f7f96480e36db93eeb8524d7e65114d96 (diff)
downloadsubsurface-51ce83ed20cd2ea493cf8118c1d85f9963f4e77f.tar.gz
Fix memory leaks in serial ftdi
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'serial_ftdi.c')
-rw-r--r--serial_ftdi.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/serial_ftdi.c b/serial_ftdi.c
index ab74b9ac1..cbac026cf 100644
--- a/serial_ftdi.c
+++ b/serial_ftdi.c
@@ -186,6 +186,7 @@ static dc_status_t serial_ftdi_open (serial_t **out, dc_context_t *context, cons
struct ftdi_context *ftdi_ctx = ftdi_new();
if (ftdi_ctx == NULL) {
+ free(device);
SYSERROR (context, errno);
return DC_STATUS_NOMEMORY;
}
@@ -205,11 +206,13 @@ static dc_status_t serial_ftdi_open (serial_t **out, dc_context_t *context, cons
ftdi_init(ftdi_ctx);
if (ftdi_set_interface(ftdi_ctx,INTERFACE_ANY)) {
+ free(device);
ERROR (context, "%s", ftdi_get_error_string(ftdi_ctx));
return DC_STATUS_IO;
}
if (serial_ftdi_open_device(ftdi_ctx) < 0) {
+ free(device);
ERROR (context, "%s", ftdi_get_error_string(ftdi_ctx));
return DC_STATUS_IO;
}
@@ -220,6 +223,7 @@ static dc_status_t serial_ftdi_open (serial_t **out, dc_context_t *context, cons
}
if (ftdi_usb_purge_buffers(ftdi_ctx)) {
+ free(device);
ERROR (context, "%s", ftdi_get_error_string(ftdi_ctx));
return DC_STATUS_IO;
}