When the size argument of calloc is 0, it should return a pointer without triggering any memory-safety issues whereas SMACK reports memory safety violations. This is because we do a memset to the malloced pointer which can be 0 when the size is 0 whereas memset is checked for valid pointer dereference. The following is a reproduction,
#include <stdlib.h>
int main() {
int *a = calloc(0, sizeof(int));
free(a);
return 0;
}
Invoking SMACK with --memory-safety produces an error.
When the
sizeargument ofcallocis 0, it should return a pointer without triggering any memory-safety issues whereas SMACK reports memory safety violations. This is because we do a memset to the malloced pointer which can be 0 when the size is 0 whereasmemsetis checked for valid pointer dereference. The following is a reproduction,Invoking SMACK with
--memory-safetyproduces an error.