gh-125234: Make PyInitConfig_Free(NULL) a no-op (#125266)

This commit is contained in:
RUANG (Roy James) 2024-10-15 17:21:16 +08:00 committed by GitHub
parent 92af191a6a
commit 546dddca43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 0 deletions

View File

@ -1621,6 +1621,8 @@ Create Config
Free memory of the initialization configuration *config*.
If *config* is ``NULL``, no operation is performed.
Error Handling
--------------

View File

@ -1896,6 +1896,7 @@ static int test_initconfig_api(void)
goto error;
}
PyInitConfig_Free(config);
PyInitConfig_Free(NULL);
dump_config();
Py_Finalize();

View File

@ -3457,6 +3457,9 @@ PyInitConfig_Create(void)
void
PyInitConfig_Free(PyInitConfig *config)
{
if (config == NULL) {
return;
}
free(config->err_msg);
free(config);
}