4 ms·
From the openbsd man page malloc(3): When using malloc() be careful to avoid the following idiom: if ((p = malloc(num * size)) == NULL)
by dmm 18y ago
From the openbsd man page malloc(3):
When using malloc() be careful to avoid the following idiom:
if ((p = malloc(num * size)) == NULL)
err(1, "malloc");
The multiplication may lead to an integer overflow. To avoid this, calloc() is recommended.
- sysop073 18y agoMaybe it's different on OpenBSD, but I think the spec says they're essentially equivalent; i.e. it's permissible to just call malloc with the product from within calloc