blob: 99a4fa11c4af7a8a2e61c2aa9b67aaf0b41e5da5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
From 68125abf821ee6ebfb4a4eb86ffe655a4c072c9e Mon Sep 17 00:00:00 2001
From: Victor Stinner <vstinner@python.org>
Date: Thu, 30 Oct 2025 15:12:24 +0100
Subject: [PATCH] fix: fix segfault after clearenv() on Python 3.15
Fix find_argv_from_env() if clearenv() has been called. Python 3.15
implements os.environ.clear() as clearenv().
Co-Authored-By: Karolina Surma <ksurma@redhat.com>
---
src/spt_setup.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/spt_setup.c b/src/spt_setup.c
index ba7a7a6..4078d36 100644
--- a/src/spt_setup.c
+++ b/src/spt_setup.c
@@ -139,6 +139,13 @@ find_argv_from_env(int argc, char *arg0)
}
buf[argc] = NULL;
+ /* environ can be NULL if clearenv() has been called.
+ * Python 3.15 implements os.environ.clear() as clearenv(). */
+ if (!environ) {
+ spt_debug("environ pointer is NULL");
+ goto exit;
+ }
+
/* Walk back from environ until you find argc-1 null-terminated strings.
* Don't look for argv[0] as it's probably not preceded by 0. */
ptr = environ[0];
|