check if index overflow in Drawing Engine