Skip to content

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 7, 2024

Don't use 'g' before it's being initialized: don't use the 'error' label if consts_dict_keys_inorder() failed.

Fix the Coverity issue:

Error: UNINIT (CWE-457):
Python-3.12.2/Python/compile.c:7670:5: skipped_decl: Jumping over declaration of ""g"". Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_block_list"" when calling ""_PyCfgBuilder_Fini"". Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_entryblock"" when calling ""_PyCfgBuilder_Fini"".
  7712|       Py_XDECREF(consts);
  7713|       instr_sequence_fini(&optimized_instrs);
  7714|->     _PyCfgBuilder_Fini(&g);
  7715|       return co;
  7716|   }

@vstinner
Copy link
Member Author

vstinner commented Jun 7, 2024

@pablogsal @lysnikolaou @isidentical: Would you mind to review this change?

cc @stratakis

@vstinner vstinner changed the title [3.12] gh-120228: Fix optimize_and_assemble_code_unit() error handling [3.12] gh-120155: Fix optimize_and_assemble_code_unit() error handling Jun 7, 2024
Don't use 'g' before it's being initialized: don't use the 'error'
label if consts_dict_keys_inorder() failed.

Fix the Coverity issue:

Error: UNINIT (CWE-457):
Python-3.12.2/Python/compile.c:7670:5: skipped_decl: Jumping over declaration of ""g"".
Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_block_list"" when calling ""_PyCfgBuilder_Fini"".
Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_entryblock"" when calling ""_PyCfgBuilder_Fini"".
  7712|       Py_XDECREF(consts);
  7713|       instr_sequence_fini(&optimized_instrs);
  7714|->     _PyCfgBuilder_Fini(&g);
  7715|       return co;
  7716|   }
@vstinner
Copy link
Member Author

vstinner commented Jun 7, 2024

The 3.13 and main branches are not affected: the code was refactored in the meanwhile.

@vstinner vstinner merged commit b3b5278 into python:3.12 Jun 7, 2024
@vstinner vstinner deleted the compile12 branch June 7, 2024 15:17
@vstinner
Copy link
Member Author

vstinner commented Jun 7, 2024

Merged, thanks for the review @iritkatriel.

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.

2 participants