C library/strdup: use calloc for an array that will be overwritten
calloc will zero-initialize the array, making it amenable to constant propagation. If subsequent updates via strcpy write constants, we can keep constant-propagating the array.
This commit is contained in:
parent
79178ce04f
commit
574513999a
|
@ -0,0 +1,8 @@
|
|||
CORE
|
||||
main.c
|
||||
--pointer-check --bounds-check --program-only
|
||||
^EXIT=0$
|
||||
^SIGNAL=0$
|
||||
--
|
||||
^warning: ignoring
|
||||
dynamic_object#\d+ WITH
|
|
@ -571,7 +571,7 @@ inline char *strdup(const char *str)
|
|||
__CPROVER_HIDE:;
|
||||
__CPROVER_size_t bufsz;
|
||||
bufsz=(strlen(str)+1);
|
||||
char *cpy=(char *)malloc(bufsz*sizeof(char));
|
||||
char *cpy = (char *)calloc(bufsz * sizeof(char), sizeof(char));
|
||||
if(cpy==((void *)0)) return 0;
|
||||
#ifdef __CPROVER_STRING_ABSTRACTION
|
||||
__CPROVER_assume(__CPROVER_buffer_size(cpy)==bufsz);
|
||||
|
|
Loading…
Reference in New Issue