Add array index check in the deallocator.