`socket` is missing a null pointer check on `PyThread_allocate_lock` return value · Issue #150406 · python/cpython · GitHub
Skip to content

socket is missing a null pointer check on PyThread_allocate_lock return value #150406

Description

@KowalskiThomas

Bug report

Bug description:

In socketmodule.c, a call is made to PyThread_allocate_lock to allocate a lock, but its return value is not checked.

cpython/Modules/socketmodule.c

Lines 9294 to 9296 in a189e3d

That same netdb_lock is later used without being checked for null-ness either.

cpython/Modules/socketmodule.c

Lines 6219 to 6237 in a189e3d

If PyThread_allocate_lock fails (due to being out of memory, that's the only failure case as far as I can tell), this will lead to a crash.

Backports

Once fix, the fix would have to be backported to 3.15 / 3.14 / 3.13 which have the same problem.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other, macOS

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions