diff --git a/public/amtl/am-string.h b/public/amtl/am-string.h index 1d1b7e2a..074339fa 100644 --- a/public/amtl/am-string.h +++ b/public/amtl/am-string.h @@ -55,6 +55,8 @@ class AString AString(const AString &other) { if (other.length_) set(other.chars_, other.length_); + else + length_ = 0; } AString(Moveable other) : chars_(other->chars_.take()), diff --git a/public/amtl/am-vector.h b/public/amtl/am-vector.h index 2e88cc33..2b0b8feb 100644 --- a/public/amtl/am-vector.h +++ b/public/amtl/am-vector.h @@ -187,10 +187,10 @@ class Vector : public AllocPolicy bool moveUp(size_t at) { assert(at < nitems_); - if (!growIfNeeded(1)) + if (!append(Moveable(data_[nitems_ - 1]))) return false; - nitems_++; - for (size_t i = nitems_ - 1; i > at; i--) + + for (size_t i = nitems_ - 2; i > at; i--) data_[i] = Moveable(data_[i - 1]); return true; }