Skip to content

Commit

Permalink
Make sure that hexrep is properly sized before appending to insertion…
Browse files Browse the repository at this point in the history
… buffer.

Close #746
Close #747
  • Loading branch information
abellgithub committed Feb 4, 2015
1 parent 60ac61f commit e39407c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugins/pgpointcloud/io/PgWriter.cpp
Expand Up @@ -451,12 +451,12 @@ void PgWriter::writeTile(PointBuffer const& buffer)

std::vector<char> storage(m_packedPointSize);
std::string hexrep;
hexrep.resize(m_packedPointSize * buffer.size() * 2);
size_t maxHexrepSize = m_packedPointSize * buffer.size() * 2;
hexrep.reserve(maxHexrepSize);

m_insert.clear();
m_insert.reserve(hexrep.size() + 3000);
m_insert.reserve(maxHexrepSize + 3000);

size_t pos = 0;
for (PointId idx = 0; idx < buffer.size(); ++idx)
{
size_t written = readPoint(buffer, idx, storage.data());
Expand All @@ -467,8 +467,8 @@ void PgWriter::writeTile(PointBuffer const& buffer)
static char syms[] = "0123456789ABCDEF";
for (size_t i = 0; i != written; i++)
{
hexrep[pos++] = syms[((storage[i] >> 4) & 0xf)];
hexrep[pos++] = syms[storage[i] & 0xf];
hexrep.push_back(syms[((storage[i] >> 4) & 0xf)]);
hexrep.push_back(syms[storage[i] & 0xf]);
}
}

Expand Down

0 comments on commit e39407c

Please sign in to comment.