summaryrefslogtreecommitdiff
path: root/Libraries/LibC/malloc.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-25 15:23:29 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-25 15:23:29 +0200
commita6b5bb439ca41a75bc5954c0b82b2a755ab2223c (patch)
treea250a816ea516b8dc55c0d3fb910068ac83009c5 /Libraries/LibC/malloc.cpp
parent3048e4b9f5b5dbcc0dfb82399fef7cab2a7abbf0 (diff)
downloadserenity-a6b5bb439ca41a75bc5954c0b82b2a755ab2223c.zip
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.
Diffstat (limited to 'Libraries/LibC/malloc.cpp')
-rw-r--r--Libraries/LibC/malloc.cpp3
1 files changed, 3 insertions, 0 deletions
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 <AK/Bitmap.h>
#include <AK/InlineLinkedList.h>
+#include <AK/ScopedValueRollback.h>
#include <AK/Vector.h>
#include <LibCore/CLock.h>
#include <assert.h>
@@ -204,6 +205,8 @@ void* malloc(size_t size)
void free(void* ptr)
{
+ ScopedValueRollback rollback(errno);
+
if (!ptr)
return;