Browse Source

core: fix a bug in the Array class copy constructor, found thanks to

the unit tests.
legacy
Sam Hocevar sam 12 years ago
parent
commit
6cd8c0ece3
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      src/array.h

+ 2
- 1
src/array.h View File

@@ -39,12 +39,13 @@ public:
ArrayBase(ArrayBase const& that) : m_data(0), m_count(0), m_reserved(0) ArrayBase(ArrayBase const& that) : m_data(0), m_count(0), m_reserved(0)
{ {
Reserve(that.m_reserved); Reserve(that.m_reserved);
memcpy(m_data, that.m_data, m_count * sizeof(Element));
memcpy(m_data, that.m_data, that.m_count * sizeof(Element));
m_count = that.m_count; m_count = that.m_count;
} }


ArrayBase& operator=(ArrayBase const& that) ArrayBase& operator=(ArrayBase const& that)
{ {
/* FIXME: delete old data!! */
m_data = 0; m_data = 0;
m_count = 0; m_count = 0;
m_reserved = 0; m_reserved = 0;


Loading…
Cancel
Save