summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qarraydataops.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h
index 02609a369e..6e75b03a72 100644
--- a/src/corelib/tools/qarraydataops.h
+++ b/src/corelib/tools/qarraydataops.h
@@ -231,10 +231,12 @@ public:
// are invalidated. However, erasing from the beginning effectively
// means that all iterators are invalidated. We can use this freedom to
// erase by moving towards the end.
- if (b == this->begin())
+ if (b == this->begin() && e != this->end()) {
this->ptr = e;
- else if (e != this->end())
- ::memmove(static_cast<void *>(b), static_cast<void *>(e), (static_cast<T *>(this->end()) - e) * sizeof(T));
+ } else if (e != this->end()) {
+ ::memmove(static_cast<void *>(b), static_cast<void *>(e),
+ (static_cast<T *>(this->end()) - e) * sizeof(T));
+ }
this->size -= n;
}
@@ -610,7 +612,7 @@ public:
// are invalidated. However, erasing from the beginning effectively
// means that all iterators are invalidated. We can use this freedom to
// erase by moving towards the end.
- if (b == this->begin()) {
+ if (b == this->begin() && e != this->end()) {
this->ptr = e;
} else {
const T *const end = this->end();
@@ -839,7 +841,7 @@ public:
// erase by moving towards the end.
std::destroy(b, e);
- if (b == this->begin()) {
+ if (b == this->begin() && e != this->end()) {
this->ptr = e;
} else if (e != this->end()) {
memmove(static_cast<void *>(b), static_cast<const void *>(e), (static_cast<const T *>(this->end()) - e)*sizeof(T));