Skip to content

Commit

Permalink
fix in Array getData and getDataCopy for segmentation fault
Browse files Browse the repository at this point in the history
  • Loading branch information
niklwors committed Aug 10, 2015
1 parent a037dd8 commit a0f0122
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions SimulationRuntime/cpp/Include/Core/Math/Array.h
Expand Up @@ -726,15 +726,22 @@ class StatArray : public BaseArray<T>
*/
virtual T* getData()
{
return _data;
if (external)
return _data;
else
return _array.c_array();

}

/**
* Access to data (read-only)
*/
virtual const T* getData() const
{
return _data;
if (external)
return _data;
else
return _array.data();
}

/**
Expand All @@ -745,7 +752,11 @@ class StatArray : public BaseArray<T>
{
if(n>0)
{
std::copy(_data, _data + n, data);
if (external)
std::copy(_data, _data + n, data);
else
std::copy(_array.begin(), _array.begin() + n, data);

}
}

Expand Down

0 comments on commit a0f0122

Please sign in to comment.