vasprintf fails by returning -1

int vasprintf(char **strp, const char *fmt, va_list ap)
return -1 on failure, not by setting strp to NULL.

Replace check for NULL by checking for -1 return.