Account for possible 0-sized elements in vector iterators

Closes #7733