Found those missing casts while looking into a crash report made in the Blender Chat. Was unable to reproduce the crash, but the casts should totally be there to avoid integer overflow.