From 5997caf45f88914dd2392c0bfff966de72bdf1c3 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 4 Jan 2018 08:50:20 -0800 Subject: [PATCH] Cleanup: avoid memory leak Coverity CID 207731 Signed-off-by: Dirk Hohndel --- src/divesystem_idive.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/divesystem_idive.c b/src/divesystem_idive.c index 46ecb34..c3d21bd 100644 --- a/src/divesystem_idive.c +++ b/src/divesystem_idive.c @@ -477,6 +477,7 @@ divesystem_idive_device_foreach (dc_device_t *abstract, dc_dive_callback_t callb WARNING(abstract->context, "Skipped unreadable dive!"); continue; } else { + dc_buffer_free(buffer); return rc; } } @@ -500,8 +501,10 @@ divesystem_idive_device_foreach (dc_device_t *abstract, dc_dive_callback_t callb (idx ) & 0xFF, (idx >> 8) & 0xFF}; rc = divesystem_idive_transfer (device, cmd_sample, sizeof(cmd_sample), packet, commands->sample.size * commands->nsamples, &errcode); - if (rc != DC_STATUS_SUCCESS) + if (rc != DC_STATUS_SUCCESS) { + dc_buffer_free(buffer); return rc; + } // If the number of samples is not an exact multiple of the // number of samples per packet, then the last packet