Skip to content

Instantly share code, notes, and snippets.

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

  • Save devdanzin/1a61f5e30036bc6aa5eac154626e4870 to your computer and use it in GitHub Desktop.

Select an option

Save devdanzin/1a61f5e30036bc6aa5eac154626e4870 to your computer and use it in GitHub Desktop.
initconfig.c: SET_ITEM macro leaks dict on expression failure

initconfig.c: SET_ITEM macro leaks dict on expression failure

Summary

SET_ITEM macro at line 510-521: when the expression (e.g., PyLong_FromLong) returns NULL, return NULL at line 514 leaks the dict allocated at line 505. The PyDict_SetItemString failure path correctly uses goto fail.

Fix

Change return NULL at line 514 to goto fail.

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