Typo fix.
Fix a bad calloc(3) call (discovered by scan-build)
Refactor a codepath in order to avoid useless goto labels

Furthermore, testing against -1 is more intuitive as most of the libc
functions and routines returns -1 on error.