Skip to content

Instantly share code, notes, and snippets.

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

  • Save devdanzin/330026d6a4c40048c771a61f706ac75e to your computer and use it in GitHub Desktop.

Select an option

Save devdanzin/330026d6a4c40048c771a61f706ac75e to your computer and use it in GitHub Desktop.
instrumentation.c: Use-after-Py_DECREF comparison in call_one_instrument

instrumentation.c: Use-after-Py_DECREF comparison in call_one_instrument

Summary

At line 992-993, Py_DECREF(res) then res compared to &_PyInstrumentation_DISABLE. Using a potentially-freed pointer in comparison is UB per C standard.

Fix

Compare before DECREF: int is_disable = (res == &_PyInstrumentation_DISABLE); Py_DECREF(res); return is_disable;

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