summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@gmail.com>2023-12-21 19:28:55 (GMT)
committerGitHub <noreply@github.com>2023-12-21 19:28:55 (GMT)
commit6b70c3dc5ab2f290fcdbe474bcb7d6fdf29eae4c (patch)
treec0471dc84d726f5398f094a1f8e3ad13f7ba86b8 /Python
parent5f7a80fd02158d9c655eff4202498f5cab9b2ca4 (diff)
downloadcpython-6b70c3dc5ab2f290fcdbe474bcb7d6fdf29eae4c.zip
cpython-6b70c3dc5ab2f290fcdbe474bcb7d6fdf29eae4c.tar.gz
cpython-6b70c3dc5ab2f290fcdbe474bcb7d6fdf29eae4c.tar.bz2
gh-113343: Fix error check on mmap(2) (#113342)
Fix error check on mmap(2) It should check MAP_FAILED instead of NULL for error. On mmap(2) man page: RETURN VALUE On success, mmap() returns a pointer to the mapped area. On error, the value MAP_FAILED (that is, (void *) -1) is returned, and errno is set to indicate the error.
Diffstat (limited to 'Python')
-rw-r--r--Python/perf_trampoline.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/perf_trampoline.c b/Python/perf_trampoline.c
index 540b650..750ba18 100644
--- a/Python/perf_trampoline.c
+++ b/Python/perf_trampoline.c
@@ -247,7 +247,7 @@ new_code_arena(void)
mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
-1, // fd (not used here)
0); // offset (not used here)
- if (!memory) {
+ if (memory == MAP_FAILED) {
PyErr_SetFromErrno(PyExc_OSError);
PyErr_FormatUnraisable("Failed to create new mmap for perf trampoline");
perf_status = PERF_STATUS_FAILED;