22 lines · cpp
1// RUN: %clangxx_hwasan %s -o %t && %run %t 2>&12 3#include <sanitizer/hwasan_interface.h>4#include <stdio.h>5#include <stdlib.h>6#include <string.h>7 8// Regression test for https://reviews.llvm.org/D107938#2961070, where, on9// reusing an allocation, we forgot to reset the short granule tag if the10// allocator was disabled. This lead to a false positive magic-string mismatch.11 12int main() {13 void *p = malloc(16);14 memset(p, 0xff, 16);15 free(p);16 17 // Relies on the LRU cache immediately recycling the allocation above.18 p = malloc(8);19 free(p); // Regression was here, in the magic-string check in the runtime.20 return 0;21}22