Skip to content

Incorrect error handling for APIs that can raise exceptions #105375

Description

@erlend-aasland

For example, in the collation callback two str objects (string1 and string2) are created using PyUnicode_FromStringAndSize. Error handling should happen directly after each call to PyUnicode_FromStringAndSize:

string1 = PyUnicode_FromStringAndSize((const char*)text1_data, text1_length);
string2 = PyUnicode_FromStringAndSize((const char*)text2_data, text2_length);
if (!string1 || !string2) {
goto finally; /* failed to allocate strings */
}

Other cases where error handling is not done immediately after the API has been used:

I might have missed some; I did not do a complete audit yet.

Linked PRs

Activity

  1. erlend-aasland commented on Jun 6, 2023

    @erlend-aasland
    Author
  2. added a commit that references this issue on Jun 6, 2023
  3. added a commit that references this issue on Jun 7, 2023
  4. added 2 commits that reference this issue on Jun 7, 2023
  5. changed the title [-]Incorrect error handling in sqlite3 collation callback[/-] [+]Missing error handling for APIs that can raise exceptions[/+] on Jun 7, 2023
  6. changed the title [-]Missing error handling for APIs that can raise exceptions[/-] [+]Incorrect error handling for APIs that can raise exceptions[/+] on Jun 7, 2023
  7. added a commit that references this issue on Jun 7, 2023
  8. 126 remaining items

  9. added a commit that references this issue on Jun 12, 2023
  10. added a commit that references this issue on Jun 12, 2023
  11. added a commit that references this issue on Jun 13, 2023
  12. added 3 commits that reference this issue on Jun 13, 2023
  13. added 2 commits that reference this issue on Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

3.11only security fixes3.12only security fixes3.13only security fixestopic-C-APItype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions