From b78bc59aa5916df41ac61a25fde16bfe7259e75e Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Thu, 11 Feb 2016 14:43:38 -0200 Subject: VoronoiSplat: fixed possible buffer overflow. --- voronoisplat.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'voronoisplat.cpp') 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 &sites = *m_sites; std::vector 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); -- cgit v1.2.3