]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-101609: Fix "‘state’ may be used uninitialized" warning in `_xxinterpchannelsmodul...
authorNikita Sobolev <mail@sobolevn.me>
Mon, 6 Feb 2023 21:05:41 +0000 (00:05 +0300)
committerGitHub <noreply@github.com>
Mon, 6 Feb 2023 21:05:41 +0000 (13:05 -0800)
I went with the easiest solution: just removing the offending line. See the issue description with my reasoning.

https://github.com/python/cpython/issues/101609

Modules/_xxinterpchannelsmodule.c

index 8601a189e87526b799d0542582abed4d5715eee9..60538c318748647ca7d3e26414ef8d1ce1b42c4a 100644 (file)
@@ -174,7 +174,9 @@ static int
 clear_module_state(module_state *state)
 {
     /* heap types */
-    (void)_PyCrossInterpreterData_UnregisterClass(state->ChannelIDType);
+    if (state->ChannelIDType != NULL) {
+        (void)_PyCrossInterpreterData_UnregisterClass(state->ChannelIDType);
+    }
     Py_CLEAR(state->ChannelIDType);
 
     /* exceptions */
@@ -2269,7 +2271,6 @@ module_exec(PyObject *mod)
     return 0;
 
 error:
-    (void)_PyCrossInterpreterData_UnregisterClass(state->ChannelIDType);
     _globals_fini();
     return -1;
 }