[PATCH 05/14] Cleanup: avoid memory leak

Dirk Hohndel dirk at hohndel.org
Thu Dec 28 16:35:33 PST 2017


Coverity CID 207731

Signed-off-by: Dirk Hohndel <dirk at hohndel.org>
---
 src/divesystem_idive.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/divesystem_idive.c b/src/divesystem_idive.c
index 46ecb3421620..642aaee4a05e 100644
--- a/src/divesystem_idive.c
+++ b/src/divesystem_idive.c
@@ -500,8 +500,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
-- 
2.15.1



More information about the devel mailing list