Language: C
Label: safe
CWE: CWE-190 \u2014 Integer Overflow or Wraparound
The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.

Code:
	consume_count(type)
		const char **type;
{
	// Note by RizinOrg:
	// to prevent the overflow check to be optimized out
	// by the compiler, this variable needs to be volatile.
	volatile int count = 0;

	if (!isdigit((unsigned char)**type))
		return -1;

	while (isdigit((unsigned char)**type)) {
		count *= 10;

		/* Check for overflow.
		   We assume that count is represented using two's-complement;
		   no power of two is divisible by ten, so if an overflow occurs
		   when multiplying by ten, the result will not be a multiple of
		   ten.  */
		if ((count % 10) != 0) {
			while (isdigit((unsigned char)**type))
				(*type)++;
			return -1;
		}

		count += **type - '0';
		(*type)++;
	}

	return (count);
}