X-Git-Url: http://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=instance.c;fp=instance.c;h=fc03174c9779bcba6d9390140d10b4f7c9c9f3a8;hp=85ff37e42e42e45fdc36416accd06d0de02b1196;hb=144a09700d242ceac48a739f9fcdb3649f4c72b8;hpb=b62ca656bcead79c54b14b0c83b0fd89ad76fb0c diff --git a/instance.c b/instance.c index 85ff37e..fc03174 100644 --- a/instance.c +++ b/instance.c @@ -182,10 +182,13 @@ SRD_API int srd_inst_option_set(struct srd_decoder_inst *di, goto err_out; } } - if (PyDict_SetItemString(py_di_options, sdo->id, py_optval) == -1) + if (PyDict_SetItemString(py_di_options, sdo->id, py_optval) == -1) { + Py_XDECREF(py_optval); goto err_out; + } /* Not harmful even if we used the default. */ g_hash_table_remove(options, sdo->id); + Py_XDECREF(py_optval); } if (g_hash_table_size(options) != 0) srd_warn("Unknown options specified for '%s'", di->inst_id); @@ -193,7 +196,6 @@ SRD_API int srd_inst_option_set(struct srd_decoder_inst *di, ret = SRD_OK; err_out: - Py_XDECREF(py_optval); if (PyErr_Occurred()) { srd_exception_catch("Stray exception in srd_inst_option_set()"); ret = SRD_ERR_PYTHON;