Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 546dddc

Browse files
authored
gh-125234: Make PyInitConfig_Free(NULL) a no-op (#125266)
1 parent 92af191 commit 546dddc

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

Doc/c-api/init_config.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,8 @@ Create Config
16211621
16221622
Free memory of the initialization configuration *config*.
16231623
1624+
If *config* is ``NULL``, no operation is performed.
1625+
16241626
16251627
Error Handling
16261628
--------------

Programs/_testembed.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,7 @@ static int test_initconfig_api(void)
18961896
goto error;
18971897
}
18981898
PyInitConfig_Free(config);
1899+
PyInitConfig_Free(NULL);
18991900

19001901
dump_config();
19011902
Py_Finalize();

Python/initconfig.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3457,6 +3457,9 @@ PyInitConfig_Create(void)
34573457
void
34583458
PyInitConfig_Free(PyInitConfig *config)
34593459
{
3460+
if (config == NULL) {
3461+
return;
3462+
}
34603463
free(config->err_msg);
34613464
free(config);
34623465
}

0 commit comments

Comments
 (0)