aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Benc <jbenc@upir.cz>2020-10-06 19:17:08 +0200
committerBartosz Golaszewski <bgolaszewski@baylibre.com>2020-10-09 14:36:13 +0200
commitc9b60ef5113b2eb386c460c5485dbd291d6c06d1 (patch)
treebd53d1d033be682f0c6efb3231b9796369e07381
parent215d6c4ca20c89ae8a9e9d0ccf3704cbde4d2674 (diff)
downloadlibgpiod-c9b60ef5113b2eb386c460c5485dbd291d6c06d1.tar.gz
bindings: python: fix Line.request() crashing
On an attempt to call the 'request' method of a Line object, the program crashes with this exception: > SystemError: ../Objects/dictobject.c:2606: bad argument to internal function > > The above exception was the direct cause of the following exception: > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > SystemError: <class 'gpiod.LineBulk'> returned a result with an error set The problem is that keyword args are NULL (rather than an empty dict) if they are not present. However, PyDict_Size sets an exception if it gets NULL. Fixes: 02a3d0a2ab5e ("bindings: python: fix segfault when calling Line.request()") Signed-off-by: Jiri Benc <jbenc@upir.cz> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
-rw-r--r--bindings/python/gpiodmodule.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/bindings/python/gpiodmodule.c b/bindings/python/gpiodmodule.c
index da72b504..3756746b 100644
--- a/bindings/python/gpiodmodule.c
+++ b/bindings/python/gpiodmodule.c
@@ -434,7 +434,7 @@ static PyObject *gpiod_Line_request(gpiod_LineObject *self,
gpiod_LineBulkObject *bulk_obj;
int rv;
- if (PyDict_Size(kwds) > 0) {
+ if (kwds && PyDict_Size(kwds) > 0) {
def_val = PyDict_GetItemString(kwds, "default_val");
def_vals = PyDict_GetItemString(kwds, "default_vals");
} else {