From a6b5bb439ca41a75bc5954c0b82b2a755ab2223c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 25 Jul 2019 15:23:29 +0200 Subject: [PATCH] LibC: Don't clobber errno in free(). This one is a bit mysterious. I can't find any authoritative answer on what the correct behavior is, but it seems reasonable to me that free() doesn't step on errno, since it returns "void" and thus the caller won't know to inspect errno anyway. --- Libraries/LibC/malloc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Libraries/LibC/malloc.cpp b/Libraries/LibC/malloc.cpp index 7ad9f087ae..7495966366 100644 --- a/Libraries/LibC/malloc.cpp +++ b/Libraries/LibC/malloc.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -204,6 +205,8 @@ void* malloc(size_t size) void free(void* ptr) { + ScopedValueRollback rollback(errno); + if (!ptr) return;