]> sigrok.org Git - libsigrokdecode.git/commitdiff
type_decoder.c: Fix a memory leak reported by scan-build.
authorUwe Hermann <redacted>
Tue, 15 May 2018 23:27:30 +0000 (01:27 +0200)
committerUwe Hermann <redacted>
Wed, 16 May 2018 10:17:42 +0000 (12:17 +0200)
  type_decoder.c:206:2: warning: Potential leak of memory pointed to by 'pdb'
          PyGILState_Release(gstate);
          ^~~~~~~~~~~~~~~~~~

type_decoder.c

index dfa3fa9e269bb5d5ae984b74290edee775a6dba6..35187a598a2d6ca19c5f09441f02955340e2468b 100644 (file)
@@ -186,12 +186,12 @@ static int convert_binary(struct srd_decoder_inst *di, PyObject *obj,
                goto err;
        }
 
-       pdb = g_malloc(sizeof(struct srd_proto_data_binary));
        if (PyBytes_AsStringAndSize(py_tmp, &buf, &size) == -1)
                goto err;
 
        PyGILState_Release(gstate);
 
+       pdb = g_malloc(sizeof(struct srd_proto_data_binary));
        pdb->bin_class = bin_class;
        pdb->size = size;
        if (!(pdb->data = g_try_malloc(pdb->size))) {