idr: fix a critical misallocation bug