[HWASAN] Fix a memory leak in realloc-test.cpp
authorKirill Stoimenov <kstoimenov@google.com>
Thu, 16 Mar 2023 05:42:02 +0000 (05:42 +0000)
committerKirill Stoimenov <kstoimenov@google.com>
Thu, 16 Mar 2023 05:43:53 +0000 (05:43 +0000)
Reviewed By: vitalybuka

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

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

index 136346f57c2ba9f8be6c510ca5373fcdc5c5a0cb..e103b609df11627f3dac9073f2d04c46bed1add2 100644 (file)
@@ -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);
 }