/////
// Functions for cache handling
-/* Constructor for StrongCacheNode */
+/* Constructor for StrongCacheNode
+ *
+ * This function doesn't set MemoryError if PyMem_Malloc fails,
+ * as the cache intentionally doesn't propagate exceptions
+ * and fails silently if error occurs.
+ */
static StrongCacheNode *
strong_cache_node_new(PyObject *key, PyObject *zone)
{
}
StrongCacheNode *new_node = strong_cache_node_new(key, zone);
+ if (new_node == NULL) {
+ return;
+ }
StrongCacheNode **root = &(state->ZONEINFO_STRONG_CACHE);
move_strong_cache_node_to_front(state, root, new_node);
PyObject *module_dict = PyModule_GetDict(module);
PyObject *error_dict = PyDict_New();
if (!module_dict || !error_dict) {
+ Py_XDECREF(error_dict);
return -1;
}
if (PyDict_SetItemString(module_dict, "errorcode", error_dict) < 0) {
}
gid_t *grouplist = PyMem_New(gid_t, len);
+ if (grouplist == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
for (Py_ssize_t i = 0; i < len; i++) {
PyObject *elem;
elem = PySequence_GetItem(groups, i);