From d2e8bd2431e759727ee0b2bf3482a6d5d9ba9c19 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 20 Apr 2015 13:55:42 +0100 Subject: [PATCH] Fix select_number crashing on empty buffers --- src/selectors.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/selectors.cc b/src/selectors.cc index 526baf53..80a8c118 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -229,13 +229,15 @@ Selection select_number(const Buffer& buffer, const Selection& selection, Object }; BufferIterator first = buffer.iterator_at(selection.cursor()); + BufferIterator last = first; if (flags & ObjectFlags::ToBegin) { skip_while_reverse(first, buffer.begin(), is_number); - if (not is_number(*first) and *first != '-') + if (not is_number(*first) and *first != '-' and + first+1 != buffer.end()) ++first; } - BufferIterator last = buffer.iterator_at(selection.cursor()); + if (flags & ObjectFlags::ToEnd) { skip_while(last, buffer.end(), is_number);