Fix uninit'd memory issues in AMTL AString and Vector (bug 5921, r=psychonic).
Fix uninit'd memory issues in AMTL AString and Vector (
bug 5921, r=psychonic).
1.1 --- a/public/amtl/am-string.h Sat Nov 30 10:51:28 2013 -0500
1.2 +++ b/public/amtl/am-string.h Sat Nov 30 10:59:05 2013 -0500
1.3 @@ -55,6 +55,8 @@
1.4 AString(const AString &other) {
1.5 if (other.length_)
1.6 set(other.chars_, other.length_);
1.7 + else
1.8 + length_ = 0;
1.9 }
1.10 AString(Moveable<AString> other)
1.11 : chars_(other->chars_.take()),
2.1 --- a/public/amtl/am-vector.h Sat Nov 30 10:51:28 2013 -0500
2.2 +++ b/public/amtl/am-vector.h Sat Nov 30 10:59:05 2013 -0500
2.3 @@ -187,10 +187,10 @@
2.4
2.5 bool moveUp(size_t at) {
2.6 assert(at < nitems_);
2.7 - if (!growIfNeeded(1))
2.8 + if (!append(Moveable<T>(data_[nitems_ - 1])))
2.9 return false;
2.10 - nitems_++;
2.11 - for (size_t i = nitems_ - 1; i > at; i--)
2.12 +
2.13 + for (size_t i = nitems_ - 2; i > at; i--)
2.14 data_[i] = Moveable<T>(data_[i - 1]);
2.15 return true;
2.16 }