Fix uninit'd memory issues in AMTL AString and Vector (bug 5921, r=psychonic).
authorKyle Sanderson <kyle.leet@gmail.com>
Sat Nov 30 10:59:05 2013 -0500 (2013-11-30)
changeset 417674365c2b1d7b
parent 4175 3ae24e84c028
child 4177 14bb936ba41f
Fix uninit'd memory issues in AMTL AString and Vector (bug 5921, r=psychonic).
public/amtl/am-string.h
public/amtl/am-vector.h
     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    }