[compiler-rt] 55ceb2e - [HWASAN] Fix a memory leak in realloc-test.cpp

Kirill Stoimenov via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 15 22:44:10 PDT 2023


Author: Kirill Stoimenov
Date: 2023-03-16T05:43:53Z
New Revision: 55ceb2eb0bf1fdfa2cbbf085fad03fe3be5c0cd5

URL: https://github.com/llvm/llvm-project/commit/55ceb2eb0bf1fdfa2cbbf085fad03fe3be5c0cd5
DIFF: https://github.com/llvm/llvm-project/commit/55ceb2eb0bf1fdfa2cbbf085fad03fe3be5c0cd5.diff

LOG: [HWASAN] Fix a memory leak in realloc-test.cpp

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D146180

Added: 
    

Modified: 
    compiler-rt/test/hwasan/TestCases/realloc-test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/hwasan/TestCases/realloc-test.cpp b/compiler-rt/test/hwasan/TestCases/realloc-test.cpp
index 136346f57c2ba..e103b609df116 100644
--- a/compiler-rt/test/hwasan/TestCases/realloc-test.cpp
+++ b/compiler-rt/test/hwasan/TestCases/realloc-test.cpp
@@ -4,12 +4,12 @@
 
 #include <assert.h>
 #include <sanitizer/hwasan_interface.h>
+#include <stdlib.h>
 
 #ifdef REALLOCARRAY
 extern "C" void *reallocarray(void *, size_t nmemb, size_t size);
 #define REALLOC(p, s) reallocarray(p, 1, s)
 #else
-#include <stdlib.h>
 #define REALLOC(p, s) realloc(p, s)
 #endif
 
@@ -41,4 +41,5 @@ int main() {
   assert(x4 != x3);
   assert(x4[0] == 10 && x4[1] == 20 && x4[2] == 30 && x4[3] == 40 &&
          x4[4] == 50);
+  free(x4);
 }


        


More information about the llvm-commits mailing list