fix potential overflow in heap pop