From 284ef21ea000f18d1eaac374679e0d0561f7bef8 Mon Sep 17 00:00:00 2001 From: Binbin Date: Sun, 14 Jan 2024 17:18:17 +0800 Subject: [PATCH] Fix fd check in memtest_test_linux_anonymous_maps (#12943) The open function returns a fd on success or -1 on failure, here we should check fd != -1, otherwise -1 will be judged as success. This closes #12938. --- src/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug.c b/src/debug.c index facbd6104..192b69d9c 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2076,7 +2076,7 @@ int memtest_test_linux_anonymous_maps(void) { int regions = 0, j; int fd = openDirectLogFiledes(); - if (!fd) return 0; + if (fd == -1) return 0; fp = fopen("/proc/self/maps","r"); if (!fp) {