소스 검색

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.
Andreas Kling 6 년 전
부모
커밋
a6b5bb439c
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      Libraries/LibC/malloc.cpp

+ 3 - 0
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;