summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-01-20 15:12:42 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2011-01-20 15:12:42 +0100
commit8edbe4daaa0948b3a718e376b9c4d2d847e4e2c1 (patch)
tree2b9b11cee7a0ee733710dbb364e0a80f4892bacd
parent48afae39d6be21d4e7c60c2b760d037103fffcaf (diff)
downloadabrt-8edbe4daaa0948b3a718e376b9c4d2d847e4e2c1.tar.gz
abrt-8edbe4daaa0948b3a718e376b9c4d2d847e4e2c1.tar.xz
abrt-8edbe4daaa0948b3a718e376b9c4d2d847e4e2c1.zip
python: fix SEGV on crash_data().get("nonexistent")
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r--src/report-python/crash_data.c4
-rwxr-xr-xsrc/report-python/test_crash_data210
2 files changed, 14 insertions, 0 deletions
diff --git a/src/report-python/crash_data.c b/src/report-python/crash_data.c
index 04a721cc..217560e5 100644
--- a/src/report-python/crash_data.c
+++ b/src/report-python/crash_data.c
@@ -82,6 +82,10 @@ static PyObject *p_get_crash_data_item(PyObject *pself, PyObject *args)
return NULL;
}
struct crash_item *ci = get_crash_data_item_or_NULL(self->cd, key);
+ if (ci == NULL)
+ {
+ Py_RETURN_NONE;
+ }
return Py_BuildValue("sI", ci->content, ci->flags);
}
diff --git a/src/report-python/test_crash_data2 b/src/report-python/test_crash_data2
new file mode 100755
index 00000000..2594f863
--- /dev/null
+++ b/src/report-python/test_crash_data2
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+
+from report import *
+
+cd = crash_data()
+cd.add("foo", "bar")
+
+print "foo:", cd.get("foo")
+print "nonexistent:", cd.get("nonexistent")
+print "done"