From d19870d9d280b1614f6bb747629652ec66cb492a Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 30 May 2014 12:41:41 -0700 Subject: [PATCH] fix another potential invalid memory access --- src/text/glyph_store.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/text/glyph_store.cpp b/src/text/glyph_store.cpp index 5e94a35f4..50084ba5f 100644 --- a/src/text/glyph_store.cpp +++ b/src/text/glyph_store.cpp @@ -40,7 +40,10 @@ const Shaping FontStack::getShaping(const std::u32string &string, const float &m for (uint32_t chr : string) { shaping.emplace_back(0, chr, x, 0); i++; - x += metrics.find(chr)->second.advance + letterSpacing; + auto metric = metrics.find(chr); + if (metric != metrics.end()) { + x += metric->second.advance + letterSpacing; + } } lineWrap(shaping, lineHeight, maxWidth, alignment, verticalAlignment);