Prevent division by 0 by bailing early
If size[0] or size[1] are <= 0, bail early in the same way as is currently done if size is NULL.
Fixes undefined behavior reported by clang's -fsanitize=float-cast-overflow where the resulting NaN is later converted to float (a UB).
Thanks to Dave Cole for the suggested fix.