]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-125234: Make PyInitConfig_Free(NULL) a no-op (#125266)
authorRUANG (Roy James) <longjinyii@outlook.com>
Tue, 15 Oct 2024 09:21:16 +0000 (17:21 +0800)
committerGitHub <noreply@github.com>
Tue, 15 Oct 2024 09:21:16 +0000 (09:21 +0000)
Doc/c-api/init_config.rst
Programs/_testembed.c
Python/initconfig.c

index 6f8962afc7af0d085480f2bb406b5e5fd2dd9ef0..66e845df2e6aa5545f35ac60f356175052e2f097 100644 (file)
@@ -1621,6 +1621,8 @@ Create Config
 
    Free memory of the initialization configuration *config*.
 
+   If *config* is ``NULL``, no operation is performed.
+
 
 Error Handling
 --------------
index ab619e32429d63a2bd3b6b88c611bd7fbd7b0967..0fb45b2265e3c695aff6cb35b99b310065ab7325 100644 (file)
@@ -1896,6 +1896,7 @@ static int test_initconfig_api(void)
         goto error;
     }
     PyInitConfig_Free(config);
+    PyInitConfig_Free(NULL);
 
     dump_config();
     Py_Finalize();
index 58ac5e7d7eaeff401fb0b6483fac86c2a66242df..c142438b02bfd9affdfa4a02028cbd0a23969204 100644 (file)
@@ -3457,6 +3457,9 @@ PyInitConfig_Create(void)
 void
 PyInitConfig_Free(PyInitConfig *config)
 {
+    if (config == NULL) {
+        return;
+    }
     free(config->err_msg);
     free(config);
 }