summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2018-05-16 00:05:42 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2018-05-16 11:46:10 +0200
commit48518538aef9dc7ceb2c603319a26ff8750f361e (patch)
tree4b7dec27b5e322a1937e49aab01ca62bf241db29
parent35c10c0e24881de50b3391b1f3ecc9e43aa361b3 (diff)
downloadlibsigrokdecode-48518538aef9dc7ceb2c603319a26ff8750f361e.tar.gz
libsigrokdecode-48518538aef9dc7ceb2c603319a26ff8750f361e.zip
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; ^~~~~~~~~~~~~~
-rw-r--r--type_decoder.c4
1 files changed, 3 insertions, 1 deletions
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;