idr: fix bounds checks