Skip to content

Commit

Permalink
pythongh-125234: Make PyInitConfig_Free(NULL) a no-op (python#125266)
Browse files Browse the repository at this point in the history
  • Loading branch information
rruuaanng authored Oct 15, 2024
1 parent 92af191 commit 546dddc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Doc/c-api/init_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,8 @@ Create Config
Free memory of the initialization configuration *config*.
If *config* is ``NULL``, no operation is performed.
Error Handling
--------------
Expand Down
1 change: 1 addition & 0 deletions Programs/_testembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,7 @@ static int test_initconfig_api(void)
goto error;
}
PyInitConfig_Free(config);
PyInitConfig_Free(NULL);

dump_config();
Py_Finalize();
Expand Down
3 changes: 3 additions & 0 deletions Python/initconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -3457,6 +3457,9 @@ PyInitConfig_Create(void)
void
PyInitConfig_Free(PyInitConfig *config)
{
if (config == NULL) {
return;
}
free(config->err_msg);
free(config);
}
Expand Down

0 comments on commit 546dddc

Please sign in to comment.