diff options
Diffstat (limited to 'libc/bionic/malloc_debug_check.cpp')
-rw-r--r-- | libc/bionic/malloc_debug_check.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/libc/bionic/malloc_debug_check.cpp b/libc/bionic/malloc_debug_check.cpp index 11a6ec1..a5d49cb 100644 --- a/libc/bionic/malloc_debug_check.cpp +++ b/libc/bionic/malloc_debug_check.cpp @@ -85,11 +85,11 @@ struct hdr_t { uintptr_t freed_bt[MAX_BACKTRACE_DEPTH]; int freed_bt_depth; size_t size; - char front_guard[FRONT_GUARD_LEN]; + uint8_t front_guard[FRONT_GUARD_LEN]; } __attribute__((packed, aligned(MALLOC_ALIGNMENT))); struct ftr_t { - char rear_guard[REAR_GUARD_LEN]; + uint8_t rear_guard[REAR_GUARD_LEN]; } __attribute__((packed)); static inline ftr_t* to_ftr(hdr_t* hdr) { @@ -126,10 +126,10 @@ static inline void init_front_guard(hdr_t* hdr) { static inline bool is_front_guard_valid(hdr_t* hdr) { for (size_t i = 0; i < FRONT_GUARD_LEN; i++) { if (hdr->front_guard[i] != FRONT_GUARD) { - return 0; + return false; } } - return 1; + return true; } static inline void init_rear_guard(hdr_t* hdr) { @@ -207,13 +207,14 @@ static inline void poison(hdr_t* hdr) { memset(user(hdr), FREE_POISON, hdr->size); } -static int was_used_after_free(hdr_t* hdr) { - unsigned i; - const char* data = reinterpret_cast<const char *>(user(hdr)); - for (i = 0; i < hdr->size; i++) - if (data[i] != FREE_POISON) - return 1; - return 0; +static bool was_used_after_free(hdr_t* hdr) { + const uint8_t* data = reinterpret_cast<const uint8_t*>(user(hdr)); + for (size_t i = 0; i < hdr->size; i++) { + if (data[i] != FREE_POISON) { + return true; + } + } + return false; } /* returns 1 if valid, *safe == 1 if safe to dump stack */ |