Fix portability issue with malloc(0)

Copied from recent Chocolate DOOM commit. See
https://github.com/chocolate-doom/chocolate-doom/commit/12a2c9441eff63f8cd3db594b826305454736182.