njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1 | /* This test demonstrated an obscure bug in malloclists handling caused by |
| 2 | multiple blocks hashing to the same list and one being overwritten at |
| 3 | realloc time due to bad ordering of the things happening. Now runs |
| 4 | without error. */ |
| 5 | |
mueller | 535cc6e | 2004-01-03 14:18:02 +0000 | [diff] [blame] | 6 | #include <stdlib.h> |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 7 | #include <stdio.h> |
| 8 | |
| 9 | int main ( void ) |
| 10 | { |
| 11 | char* p; |
| 12 | int i; |
| 13 | for (i = 0; i < 10000; i++) { |
| 14 | p = malloc(10 + 10 * (i % 100)); |
| 15 | p = realloc(p, 500); |
| 16 | p = realloc(p, 600); |
| 17 | free(p); |
| 18 | } |
| 19 | return 0; |
| 20 | } |
| 21 | |