rem: if (buffer == NULL || bufferSize == 0)
add: if (bufferSize == 0)
context: vsnprintf(char *buffer, size_t bufferSize, const char *format, va_list args){	int32 bytesLeft;	uint64 num;	int base;	char *string;	int flags;			/* flags to number() */	int fieldWidth;	/* width of output field */	int precision;				/* min. # of digits for integers; max number of chars for from string */	int qualifier;		/* 'h', 'l', or 'L' for integer fields */	if (buffer == NULL || bufferSize == 0)		return 0;	bytesLeft = ((int32)bufferSize - 1) & 0x7fffffff;		// make space for the terminating '\0' byte, and we		// only allow 2G characters :)	for (string = buffer; format[0] && bytesLeft > 0; format++) {		if (format[0] != '%') {			if (!put_character(&string, &bytesLeft, format[0]))				break;			continue;		}		/* process flags */		flags = 0;	repeat:		++format;		/* this also skips first '%' */		switch (format[0]) {			case '-': flags |= LEFT; goto repeat;			case '+': flags |= PLUS; goto repeat;			case ' ': flags |= SPACE; goto repeat;			case '#': flags |= SPECIAL; goto repeat;			case '0': flags |= ZEROPAD; goto repeat;		}		/* get field width */		fieldWidth = -1;		if (isdigit(*format))			fieldWidth = skip_atoi(&format);		else if (format[0] == '*') {			++format;			/* it's the next argument */			fieldWidth = va_arg(args, int);			if (fieldWidth < 0) {				fieldWidth = -fieldWidth;				flags |= LEFT;			}		}		/* get the precision */		precision = -1;		if (format[0] == '.') {			++format;				if (isdigit(*format))				precision = skip_atoi(&format);			else if (format[0] == '*') {				++format;				/* it's the next argument */				precision = va_arg(args, int);			}			if (precision < 0)				precision = 0;		}		/* get the conversion qualifier */		qualifier = -1;		if (format[0] == 'h' || format[0] == 'l' || format[0] == 'L')			qualifier = *format++;		/* default base */		base = 10;		switch (format[0]) {			case 'c':				if (!(flags & LEFT) && !put_padding(&string, &bytesLeft, fieldWidth))					goto out;				put_character(&string, &bytesLeft, (char)va_arg(args, int));				if ((flags & LEFT) != 0 && !put_padding(&string, &bytesLeft, fieldWidth))					goto out;				continue;			case 's':			{				const char *argument = va_arg(args, char *);				int32 length;				if (argument == NULL)					argument = "<NULL>";				length = strnlen(argument, precision);				if (!(flags & LEFT) && !put_padding(&string, &bytesLeft, fieldWidth))					goto out;				if (!put_string(&string, &bytesLeft, argument, length))					goto out;				if ((flags & LEFT) != 0 && !put_padding(&string, &bytesLeft, fieldWidth))					goto out;				continue;			}			case 'p':				if (fieldWidth == -1) {					fieldWidth = 2*sizeof(void *);					flags |= ZEROPAD;				}				// ToDo: fix me!				string[0] = '0';				string[1] = 'x';				string = number(string + 2, (uint32)va_arg(args, void *), 16,						fieldWidth, precision, flags);				continue;			case 'n':				if (qualifier == 'l') {					long *ip = va_arg(args, long *);					*ip = (string - buffer);				} else {					int *ip = va_arg(args, int *);					*ip = (string - buffer);				}				continue;			/* integer number formats - set up the flags and "break" */			case 'o':				base = 8;				break;			case 'X':				flags |= LARGE;			case 'x':				base = 16;				break;			case 'd':			case 'i':				flags |= SIGN;			case 'u':				break;			default:				if (format[0] != '%')					put_character(&string, &bytesLeft, '%');				if (!format[0])					goto out;				put_character(&string, &bytesLeft, format[0]);				continue;		}		if (qualifier == 'L')			num = va_arg(args, unsigned long long);		else if (qualifier == 'l') {			num = va_arg(args, unsigned long);			if (flags & SIGN)				num = (long)num;		} else if (qualifier == 'h') {			num = (unsigned short)va_arg(args, int);			if (flags & SIGN)				num = (short)num;		} else if (flags & SIGN)			num = va_arg(args, int);		else			num = va_arg(args, unsigned int);		// ToDo: fix me!		string = number(string, num, base, fieldWidth, precision, flags);	}out:	*string = '\0';	return string - buffer;}