From dc244432932a2e727f0dec191861e4b46c327269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Thu, 25 May 2017 23:53:08 +0200 Subject: Fix out of bounds array access in font.cc. --- plugingui/font.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugingui') diff --git a/plugingui/font.cc b/plugingui/font.cc index a56d392..9f54b16 100644 --- a/plugingui/font.cc +++ b/plugingui/font.cc @@ -37,7 +37,7 @@ Font::Font(const std::string& fontfile) std::size_t px = 0; std::size_t c; - for(c = 0; c < (characters.size() - 1) && px < img_font.width(); ++c) + for(c = 0; c < characters.size() && px < img_font.width(); ++c) { auto& character = characters[c]; character.offset = px + 1; @@ -71,7 +71,7 @@ Font::Font(const std::string& fontfile) characters[c] = character; } - ++c; + --c; assert(characters[c].offset >= characters[c - 1].offset); characters[c - 1].width = characters[c].offset - characters[c - 1].offset; -- cgit v1.2.3