Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NULL checks after PyTuple_Pack calls to prevent potential errors #128

Open
sourcery-ai bot opened this issue Dec 3, 2024 · 0 comments
Open

Add NULL checks after PyTuple_Pack calls to prevent potential errors #128

sourcery-ai bot opened this issue Dec 3, 2024 · 0 comments

Comments

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 3, 2024

The codebase currently lacks NULL checks after calls to PyTuple_Pack, which can return NULL on error. This issue poses a bug risk as it can lead to unexpected behavior or crashes if the error is not handled properly.

The specific instance mentioned is in the code where PyTuple_Pack is used without checking for a NULL return value. The suggested fix is to add a NULL check immediately after the PyTuple_Pack call, as follows:

PyObject *tuple = PyTuple_Pack(2, path, retval);
if (tuple == NULL) {
    return NULL;
}

Additionally, there are other files such as kvitems_basecoro.c and parse_basecoro.c that also lack these checks. It is recommended to perform a comprehensive review and update all instances where PyTuple_Pack is used without a NULL check across the codebase. A separate commit addressing all these instances would be beneficial to ensure consistency and robustness in error handling.


I created this issue for @wodny from #127 (comment).

Tips and commands

Interacting with Sourcery

  • Generate a plan of action: Comment @sourcery-ai plan on this issue.
  • Generate a pull request for this issue: Comment @sourcery-ai develop to
    generate a PR that addresses this issue.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants