From 3d89af272b718dd30a60f351149fde95958acfb0 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 23 May 2016 16:08:17 +0200 Subject: [PATCH] COMMON: Fix SortedArray implementation for empty array --- common/array.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/array.h b/common/array.h index 869d79b68bf..29a1ff84707 100644 --- a/common/array.h +++ b/common/array.h @@ -378,6 +378,11 @@ public: * Inserts element at the sorted position. */ void insert(const T &element) { + if (!this->_size) { + this->insert_aux(this->_storage, &element, &element + 1); + return; + } + T *where = (T *)bsearchMin(element, this->front(), this->_size, sizeof(T), _comparator); insert(where, element); }