Skip to content

_xxinterpchannelsmodule.c incorrect error handling in SET_COUNT macro #115498

Closed
@sobolevn

Description

@sobolevn

Bug report

Right now it uses Py_DECREF(info), which is strange, because info has struct channel_info * type.

But, it does not clear PyObject *self = PyStructSequence_New(state->ChannelInfoType); which is declared right above. I think that this might be a typo.

Link:

new_channel_info(PyObject *mod, struct channel_info *info)
{
module_state *state = get_module_state(mod);
if (state == NULL) {
return NULL;
}
assert(state->ChannelInfoType != NULL);
PyObject *self = PyStructSequence_New(state->ChannelInfoType);
if (self == NULL) {
return NULL;
}
int pos = 0;
#define SET_BOOL(val) \
PyStructSequence_SET_ITEM(self, pos++, \
Py_NewRef(val ? Py_True : Py_False))
#define SET_COUNT(val) \
do { \
PyObject *obj = PyLong_FromLongLong(val); \
if (obj == NULL) { \
Py_CLEAR(info); \
return NULL; \
} \
PyStructSequence_SET_ITEM(self, pos++, obj); \
} while(0)

I have a PR ready.

Linked PRs

Metadata

Metadata

Assignees

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions