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:
static void ep4_mul_pre_ordin(ep4_t *t, const ep4_t p) {
	ep4_dbl(t[0], p);
#if defined(EP_MIXED)
	ep4_norm(t[0], t[0]);
#endif

#if EP_DEPTH > 2
	ep4_add(t[1], t[0], p);
	for (int i = 2; i < (1 << (EP_DEPTH - 2)); i++) {
		ep4_add(t[i], t[i - 1], t[0]);
	}

#if defined(EP_MIXED)
	for (int i = 1; i < (1 << (EP_DEPTH - 2)); i++) {
		ep4_norm(t[i], t[i]);
	}
#endif

#endif
	ep4_copy(t[0], p);
}