Add another bounds check, use intptr_t for pointer comparisons