2012.12.12 23:42 "[Tiff] Dealing with unportability of malloc(0)", by Tom Lane

2012.12.13 09:28 "Re: [Tiff] Dealing with unportability of malloc(0)", by Graeme Gill

Zero means means overflow is definitely convenient. Otherwise you would need to arrange to return from the problem code right away or produce both the computed size value and a pass/fail value, with additional conditional code.

Another approach is to use saturation arithmetic for such calculations. malloc(SIZE_MAX) will fail.

Graeme Gill.