3 ms·
The real reason "calloc" exists was that it was really easy to hit 16-bit overflow back in the PDP-11 days.
by Animats 10y ago
The real reason "calloc" exists was that it was really easy to hit 16-bit overflow back in the PDP-11 days.
- raphaelj 10y agoThank you for this answer. The answers from OP were not convincing me.
- raphaelj 10y agoThank you for this answer. The answers from OP were not convincing me.
- LukeShu 10y agoHistorically, not quite true. No version of Research UNIX V1 through V7, nor any of BSD 1, 2, 3, 4, or 4.4 did overflow checking. They all just did `m * n` or `m *= n`.
- jcranmer 10y agoIf you look through the history of CVEs, you'll find that pretty much every implementation of calloc or a calloc-like function starts with m * n and ends up only changing after someone points out the security flaw.