Skip to content

Instantly share code, notes, and snippets.

@devdanzin
Created March 18, 2026 10:07
Show Gist options
  • Select an option

  • Save devdanzin/829b08903c28f8e345052256cb1b7cb4 to your computer and use it in GitHub Desktop.

Select an option

Save devdanzin/829b08903c28f8e345052256cb1b7cb4 to your computer and use it in GitHub Desktop.
termios.c: tcsetwinsize passes NULL to PyLong_AsLong

termios.c: tcsetwinsize passes NULL to PyLong_AsLong

CPython issue: python/cpython#146091

Summary

tcsetwinsize in Modules/termios.c (lines 502-510) passes the result of PySequence_GetItem directly to PyLong_AsLong without NULL check. On error, PyLong_AsLong(NULL) calls PyErr_BadInternalCall()SystemError masks the real error.

Fix

Check PySequence_GetItem return for NULL before calling PyLong_AsLong.

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