2009-06-18 18:16:21 +00:00
|
|
|
From 07b1c4c8a736a31ac4b8ae13ea25d50793dfea83 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Mike Gorse <mgorse@alum.wpi.edu>
|
|
|
|
|
Date: Fri, 25 Jan 2019 12:55:52 -0600
|
|
|
|
|
Subject: [PATCH] python: return None if PY_IMPORT_STRING returns NULL
|
|
|
|
|
|
|
|
|
|
PY_IMPORT_STRING might return NULL on python 3 if, ie, a string can't be
|
|
|
|
|
encoded. We should check for this and return None, rather than returning
|
|
|
|
|
NULL. Fixes a NULL pointer dereference when reporting an error with an
|
|
|
|
|
invalid string.
|
|
|
|
|
---
|
2019-01-28 07:51:27 +00:00
|
|
|
python/types.c | 4 ++++
|
2009-06-18 18:16:21 +00:00
|
|
|
1 file changed, 4 insertions(+)
|
|
|
|
|
|
2019-01-28 07:51:27 +00:00
|
|
|
diff --git a/python/types.c b/python/types.c
|
|
|
|
|
index 124af565..50951ba3 100644
|
|
|
|
|
--- a/python/types.c
|
|
|
|
|
+++ b/python/types.c
|
|
|
|
|
@@ -150,6 +150,10 @@ libxml_charPtrConstWrap(const char *str)
|
2009-06-18 18:16:21 +00:00
|
|
|
return (Py_None);
|
|
|
|
|
}
|
|
|
|
|
ret = PY_IMPORT_STRING(str);
|
|
|
|
|
+ if (ret == NULL) {
|
|
|
|
|
+ Py_INCREF(Py_None);
|
|
|
|
|
+ return (Py_None);
|
|
|
|
|
+ }
|
|
|
|
|
return (ret);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-28 07:51:27 +00:00
|
|
|
--
|
|
|
|
|
2.18.0
|
|
|
|
|
|