Added missing index check on vec_pop()