After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 678338 - Unchecked return value
Unchecked return value
Status: RESOLVED FIXED
Product: libpeas
Classification: Platform
Component: python
git master
Other Linux
: Normal normal
: ---
Assigned To: libpeas-maint
libpeas-maint
Depends on:
Blocks:
 
 
Reported: 2012-06-18 16:54 UTC by Barry Warsaw
Modified: 2014-08-22 19:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Bug 678338 - Check return values from Python API (5.27 KB, patch)
2014-06-28 13:05 UTC, Garrett Regier
committed Details | Review

Description Barry Warsaw 2012-06-18 16:54:11 UTC
While investigating Python 3 support, I noticed a few minor issues where return values are not checked for errors.  In practice these may never occur, but to be safe, it's best to check and handle these possible errors.

in peas-plugin-loader-python.c, in peas_plugin_loader_python_initialize(), after the PyErr_Occurred() check on line 407, you can potentially get errors in the following calls:

PyModule_GetDict(),
PyDict_GetItemString()
Py_BuildValue()
PyObject_CallObject()
PyEval_SafeThread()

These all fall straight through to the `return TRUE`, so unless the caller is checking for PyErr_Occurred(), failures will cause mysterious exceptions far from the failing call site.

Other cases occur in peas_plugin_loader_python_add_module_path() such as the call to PySys_GetObject(), Py{String,Unicode}_FromString(), and PyList_Insert().

Also in peas_plugin_loader_python_create_extension(), unchecked are PyObject_SetAttrString().  There may be other cases I've missed.
Comment 1 Garrett Regier 2014-06-28 13:05:54 UTC
Created attachment 279482 [details] [review]
Bug 678338 - Check return values from Python API
Comment 2 Garrett Regier 2014-08-22 19:36:12 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.