]> sigrok.org Git - libsigrokdecode.git/commitdiff
decoder.c: Fix a scan-build warning.
authorUwe Hermann <redacted>
Tue, 15 May 2018 22:21:56 +0000 (00:21 +0200)
committerUwe Hermann <redacted>
Wed, 16 May 2018 10:17:42 +0000 (12:17 +0200)
  decoder.c:343:9: warning: Access to field 'ob_type' results in a dereference of a null pointer (loaded from variable 'py_default')
                                  if (Py_TYPE(py_default) != Py_TYPE(py_item)) {
                                      ^~~~~~~~~~~~~~~~~~~
  /usr/include/python3.6m/object.h:118:33: note: expanded from macro 'Py_TYPE'
  #define Py_TYPE(ob)             (((PyObject*)(ob))->ob_type)
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

decoder.c

index 21b756ba370620bf99db2aefb8a31f0f7f9c6b10..bebe96cb8a9b8afe0932d22de1f9070b69717147 100644 (file)
--- a/decoder.c
+++ b/decoder.c
@@ -340,7 +340,7 @@ static int get_options(struct srd_decoder *d)
                                if (!py_item)
                                        goto except_out;
 
-                               if (Py_TYPE(py_default) != Py_TYPE(py_item)) {
+                               if (py_default && (Py_TYPE(py_default) != Py_TYPE(py_item))) {
                                        srd_err("All values for option '%s' must be "
                                                "of the same type as the default.",
                                                o->id);