News for hackers. Stuff that matters.
Re:Why Does Calloc Exist? by zoomablemind on Sunday November 13, 2022 @12:17PM (#33585044)
> if (n && m > (size_t)-1/n)

Shouldn't the case of wraparound be caught by testing the resulting size as following?

  s = n*m;
  if (n && s >= n && s >= m) /* no overflow */ ...
Re:Why Does Calloc Exist? by CUViper on Sunday November 13, 2022 @01:50PM (#33586093)
That doesn't work for multiplication -- e.g. in 8-bit, 20 * 20 wraps to 144.