Validating buffer for small list

Things get messed when there are not enough items in the list. If we use '<', the buffer.top might be set to a negative value.