From 48518538aef9dc7ceb2c603319a26ff8750f361e Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Wed, 16 May 2018 00:05:42 +0200 Subject: [PATCH] type_decoder.c: Fix a memory leak reported by scan-build. type_decoder.c:197:10: warning: Potential leak of memory pointed to by 'pdb' return SRD_ERR_MALLOC; ^~~~~~~~~~~~~~ --- type_decoder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/type_decoder.c b/type_decoder.c index a61a475..dfa3fa9 100644 --- a/type_decoder.c +++ b/type_decoder.c @@ -194,8 +194,10 @@ static int convert_binary(struct srd_decoder_inst *di, PyObject *obj, pdb->bin_class = bin_class; pdb->size = size; - if (!(pdb->data = g_try_malloc(pdb->size))) + if (!(pdb->data = g_try_malloc(pdb->size))) { + g_free(pdb); return SRD_ERR_MALLOC; + } memcpy((void *)pdb->data, (const void *)buf, pdb->size); pdata->data = pdb; -- 2.30.2