Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-146245: Fix ref/buffer leaks in socketmodule.c on audit hook failure#146247

Closed
kimimgo wants to merge 1 commit into
python:mainpython/cpython:mainfrom
kimimgo:fix/socket-audit-leak-146245kimimgo/cpython:fix/socket-audit-leak-146245Copy head branch name to clipboard
Closed

gh-146245: Fix ref/buffer leaks in socketmodule.c on audit hook failure#146247
kimimgo wants to merge 1 commit into
python:mainpython/cpython:mainfrom
kimimgo:fix/socket-audit-leak-146245kimimgo/cpython:fix/socket-audit-leak-146245Copy head branch name to clipboard

Conversation

@kimimgo

@kimimgo kimimgo commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #146245

Summary

Two leak bugs in socketmodule.c when PySys_Audit raises:

1. getaddrinfo (line 6985)

return NULL skipped cleanup of idna and pstr refs. Changed to
goto err which properly calls Py_XDECREF on both.

2. sock_sendto (line 4811)

return NULL skipped PyBuffer_Release(&pbuf). Added the release
before the return, matching the pattern used in adjacent error paths.

… failure

Fix two leak bugs in socketmodule.c when PySys_Audit raises:

1. getaddrinfo: 'return NULL' replaced with 'goto err' to ensure
   idna and pstr refs are properly released via Py_XDECREF.

2. sock_sendto: Added PyBuffer_Release(&pbuf) before 'return NULL'
   to release the Py_buffer when audit hook raises.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

socketmodule.c: Reference and buffer leaks via audit hook failures

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.