summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-09-17 19:35:00 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2018-09-22 20:46:32 +0200
commitaccc4dcd1140fbc1150e8dd9293396a95a093128 (patch)
tree5a7056adc94ce686af78c0923f007e87b32fd892
parent1e9a0872b4a44f168d205f6ab65391aff7d919f7 (diff)
downloadpygobject-accc4dcd1140fbc1150e8dd9293396a95a093128.tar.gz
foreign-cairo: add error handling for the pygobject API initialization
I can fail in case it's called at the wrong point in pygobject's own module init phase, which is what I tried.
-rw-r--r--gi/pygi-foreign-cairo.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gi/pygi-foreign-cairo.c b/gi/pygi-foreign-cairo.c
index c398cb72..718f9a0f 100644
--- a/gi/pygi-foreign-cairo.c
+++ b/gi/pygi-foreign-cairo.c
@@ -539,6 +539,8 @@ cairo_matrix_release (GIBaseInfo *base_info,
static PyMethodDef _gi_cairo_functions[] = { {0,} };
PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
{
+ PyObject *gobject_mod;
+
#if PY_VERSION_HEX < 0x03000000
Pycairo_IMPORT;
#else
@@ -548,7 +550,10 @@ PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
if (Pycairo_CAPI == NULL)
return PYGLIB_MODULE_ERROR_RETURN;
- pygobject_init (3, 13, 2);
+ gobject_mod = pygobject_init (3, 13, 2);
+ if (gobject_mod == NULL)
+ return PYGLIB_MODULE_ERROR_RETURN;
+ Py_DECREF (gobject_mod);
pygi_register_foreign_struct ("cairo",
"Matrix",