Use an equivalent division instead of multiplying values and checking if they are more than G_MAXINT32, because divisions cannot overflow. (cherry picked from commit f63ba36d)