diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2021-12-26 13:27:44 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2021-12-26 13:27:44 +0300 |
commit | c87fd33b6b1a924e607e081c61e7e391edc4d21b (patch) | |
tree | 2c1e84dab73ef462c1238a3d6c63f0a5c9378ea9 | |
parent | 166d6e07dc9d54599ab1ecba46dbca530b4e7217 (diff) | |
download | bdwgc-c87fd33b6b1a924e607e081c61e7e391edc4d21b.tar.gz |
Eliminate code defect about incorrect size of allocated object (leaktest)
* tests/leak_test.c (main): Change type p local variable from int** to
char** one.
-rw-r--r-- | tests/leak_test.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/leak_test.c b/tests/leak_test.c index 74eb6a0b..86a38fc9 100644 --- a/tests/leak_test.c +++ b/tests/leak_test.c @@ -2,7 +2,7 @@ #include "gc/leak_detector.h" int main(void) { - int *p[10]; + char *p[10]; int i; GC_set_find_leak(1); /* for new collect versions not compiled */ /* with -DFIND_LEAK. */ @@ -10,14 +10,14 @@ int main(void) { GC_INIT(); /* Needed if thread-local allocation is enabled. */ /* FIXME: This is not ideal. */ for (i = 0; i < 10; ++i) { - p[i] = (int*)malloc(sizeof(int)+i); + p[i] = (char*)malloc(sizeof(int)+i); } CHECK_LEAKS(); for (i = 1; i < 10; ++i) { free(p[i]); } for (i = 0; i < 9; ++i) { - p[i] = (int*)malloc(sizeof(int)+i); + p[i] = (char*)malloc(sizeof(int)+i); } CHECK_LEAKS(); CHECK_LEAKS(); |