aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2016-02-11 14:43:38 -0200
committerSamuel Fadel <samuelfadel@gmail.com>2016-02-11 14:43:38 -0200
commitb78bc59aa5916df41ac61a25fde16bfe7259e75e (patch)
tree819dc83db070daa7dfc132edd68e8fc5d131113f
parentb5ca997b2d2a64f955b78208d0362cba0278f8d3 (diff)
VoronoiSplat: fixed possible buffer overflow.
-rw-r--r--voronoisplat.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/voronoisplat.cpp b/voronoisplat.cpp
index f1ed821..da81817 100644
--- a/voronoisplat.cpp
+++ b/voronoisplat.cpp
@@ -524,7 +524,13 @@ void VoronoiSplatRenderer::computeDT()
const std::vector<float> &sites = *m_sites;
std::vector<float> buf(w*h);
for (unsigned i = 0; i < sites.size(); i += 2) {
- buf[int(m_sy(sites[i + 1]))*h + int(m_sx(sites[i]))] = i/2.0f + 1.0f;
+ unsigned bufIndex = unsigned(m_sy(sites[i + 1]))*h + unsigned(m_sx(sites[i]));
+ if (bufIndex > buf.size()) {
+ // points outside our scale
+ continue;
+ }
+
+ buf[bufIndex] = i/2.0f + 1.0f;
}
skelft2DFT(0, buf.data(), 0, 0, w, h, w);