Commit 4b37fcd4 authored by Dan Lipsa's avatar Dan Lipsa

BUG: push_back may cause pointers to become invalid

Pointers to strings stored in a vector are kept, however
new strings are added using push_back which causes the
pointers to become invalid. This behavior was only seen
on mac os as the vector was small so reallocation did not
happen on other platforms.
parent d3313b1b
......@@ -205,13 +205,14 @@ int vtkGeoProjection::UpdateProjection()
pjArgs[2] = meridSpec.c_str();
// Add optional parameters
std::vector<std::string> stringHolder; // Keep string ref in memory
std::vector<std::string> stringHolder(
this->GetNumberOfOptionalParameters()); // Keep string ref in memory
for(int i=0; i < this->GetNumberOfOptionalParameters(); i++)
{
std::ostringstream param;
param << "+" << this->GetOptionalParameterKey(i);
param << "=" << this->GetOptionalParameterValue(i);
stringHolder.push_back(param.str());
stringHolder[i] = param.str();
pjArgs[3+i] = stringHolder[i].c_str();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment