summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2019-05-07 13:25:01 +1200
committerDouglas Bagnall <dbagnall@samba.org>2019-05-09 22:39:27 +0000
commit06068603084562be40f3180561fe7af5700ff4e8 (patch)
treed2e77826c743450f07b22228f11c04133e72fad6
parent4954a96e45333147c12466ddcea21aa9c364acb5 (diff)
downloadsamba-06068603084562be40f3180561fe7af5700ff4e8.tar.gz
pyrpc: ndr PY_CHECK_TYPE checks for NULL as well as type
Addresses CID 1361477 and others. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
-rw-r--r--source4/librpc/rpc/pyrpc.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/source4/librpc/rpc/pyrpc.h b/source4/librpc/rpc/pyrpc.h
index 968bf863c4c..05c1adb8307 100644
--- a/source4/librpc/rpc/pyrpc.h
+++ b/source4/librpc/rpc/pyrpc.h
@@ -26,10 +26,19 @@
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#endif
-#define PY_CHECK_TYPE(type, var, fail) \
- if (!PyObject_TypeCheck(var, type)) {\
- PyErr_Format(PyExc_TypeError, __location__ ": Expected type '%s' for '%s' of type '%s'", (type)->tp_name, #var, Py_TYPE(var)->tp_name); \
- fail; \
+#define PY_CHECK_TYPE(type, var, fail) \
+ if (var == NULL) { \
+ PyErr_Format(PyExc_TypeError, \
+ __location__ \
+ ": Expected type '%s' for '%s', got NULL", \
+ (type)->tp_name, #var); \
+ fail; \
+ } else if (!PyObject_TypeCheck(var, type)) { \
+ PyErr_Format(PyExc_TypeError, \
+ __location__ \
+ ": Expected type '%s' for '%s' of type '%s'", \
+ (type)->tp_name, #var, Py_TYPE(var)->tp_name); \
+ fail; \
}
#define dom_sid0_Type dom_sid_Type