/
niceSOFT
/
valgrind
Обзор
Документация
Войти
/
niceSOFT
/
valgrind
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
memcheck/tests/malloc3.c
34 строки
746 B
Nicholas Nethercote
Fixed bug 149878 (calloc overflow). This disables some of the calloc silly
24 июл 2009, 10:41
24 июл 2009, 10:41
e3f6e42
Код
Авторство
О чём код?
/* test of plausible behaviour with malloc and stupid args */ #include <stdlib.h> #include <stdio.h> int main ( void ) { char* p; p = malloc(0); printf("malloc(0) = 0x%lx\n", (unsigned long)p); free(p); p = malloc(-1); printf("malloc(-1) = 0x%lx\n", (unsigned long)p); free(p); p = calloc(0,1); printf("calloc(0,1) = 0x%lx\n", (unsigned long)p); free(p); p = calloc(0,-1); printf("calloc(0,-1) = 0x%lx\n", (unsigned long)p); free(p); // We no longer get a warning with this due to the calloc overflow checking // done for bug 149878. It's no great loss, it's extremely unlikely to // occur in practice. p = calloc(-1,-1); printf("calloc(-1,-1) = 0x%lx\n", (unsigned long)p); free(p); return 0; }