gstmodule: Check that we could retrieve the module before using it

And plug a small leak
This commit is contained in:
Thibault Saunier 2013-08-23 21:42:37 -04:00
parent cfa8710b7b
commit 2ac104ea94

View file

@ -53,9 +53,24 @@ gi_gst_fraction_from_value (const GValue * value)
denominator = gst_value_get_fraction_denominator (value);
module = PyImport_ImportModule ("gi.repository.Gst");
if (module == NULL) {
PyErr_SetString (PyExc_KeyError,
"Could not get module for gi.repository.Gst");
return NULL;
}
dict = PyModule_GetDict (module);
Py_DECREF (module);
/* For some reson we need this intermediary step */
module = PyMapping_GetItemString (dict, "_overrides_module");
if (module == NULL) {
PyErr_SetString (PyExc_KeyError,
"Could not get module for _overrides_module");
return NULL;
}
dict = PyModule_GetDict (module);
fraction_type = PyMapping_GetItemString (dict, "Fraction");