gh-151126: Fix missing memory errors in _interpqueuesmodule.c#151639
gh-151126: Fix missing memory errors in _interpqueuesmodule.c#151639lpyu001 wants to merge 3 commits into
Conversation
sobolevn
left a comment
There was a problem hiding this comment.
Please, take a look that _queueid_xid_new also has another problem. It returns NULL here:
_queues *queues = _get_global_queues();
if (_queues_incref(queues, qid) < 0) {
return NULL;
}without an exception set. Because _queues_incref sets res = ERR_QUEUE_NOT_FOUND; but sets no exception.
| @@ -1045,6 +1045,7 @@ _queues_list_all(_queues *queues, int64_t *p_count) | |||
| struct queue_id_and_info *ids = PyMem_NEW(struct queue_id_and_info, | |||
There was a problem hiding this comment.
While we are at it: can you please refactor a deprecated alias PyMem_NEW to be PyMem_New?
| if (_queues_incref(queues, qid) < 0) { | ||
| int err = _queues_incref(queues, qid); | ||
| if (err < 0) { | ||
| PyObject *mod = PyImport_ImportModule(MODULE_NAME_STR); |
There was a problem hiding this comment.
I am not sure that this is correct. It can replace an existing error with accidental ImportError. If it fails.
Maybe we can raise the error directly? We know that only ERR_QUEUE_NOT_FOUND can happen.
Or maybe you have other ideas? :)
There was a problem hiding this comment.
Thanks, that makes sense. I’m not very familiar with this import/module-state error path,I updated it to avoid importing here and use _get_current_module() before handle_queue_error().
PyErr_NoMemory()call after failing memory allocation #151126