Skip to content

Commit 5f1844a

Browse files
committed
Merge branch 'bugfix/heap_poison_swap_check' into 'master'
heap: When verifying & swapping a fill pattern, stop swapping if verification fails See merge request idf/esp-idf!2890
2 parents 084ca82 + 8cbd12b commit 5f1844a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

components/heap/multi_heap_poisoning.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ static bool verify_fill_pattern(void *data, size_t size, bool print_errors, bool
147147
MULTI_HEAP_STDERR_PRINTF("CORRUPT HEAP: Invalid data at %p. Expected 0x%08x got 0x%08x\n", p, EXPECT_WORD, *p);
148148
}
149149
valid = false;
150+
#ifndef NDEBUG
151+
/* If an assertion is going to fail as soon as we're done verifying the pattern, leave the rest of the
152+
buffer contents as-is for better post-mortem analysis
153+
*/
154+
swap_pattern = false;
155+
#endif
150156
}
151157
if (swap_pattern) {
152158
*p = REPLACE_WORD;
@@ -164,6 +170,9 @@ static bool verify_fill_pattern(void *data, size_t size, bool print_errors, bool
164170
MULTI_HEAP_STDERR_PRINTF("CORRUPT HEAP: Invalid data at %p. Expected 0x%02x got 0x%02x\n", p, (uint8_t)EXPECT_WORD, *p);
165171
}
166172
valid = false;
173+
#ifndef NDEBUG
174+
swap_pattern = false; // same as above
175+
#endif
167176
}
168177
if (swap_pattern) {
169178
p[i] = (uint8_t)REPLACE_WORD;

0 commit comments

Comments
 (0)