aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/graphics/text32.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp
index d1c223d5d5..62664c1aa2 100644
--- a/engines/sci/graphics/text32.cpp
+++ b/engines/sci/graphics/text32.cpp
@@ -498,7 +498,7 @@ int16 GfxText32::getTextWidth(const uint index, uint length) const {
--length;
fontId = fontId * 10 + currentChar - '0';
- } while (length > 0 && currentChar >= '0' && currentChar <= '9');
+ } while (length > 0 && *text >= '0' && *text <= '9');
if (length > 0) {
font = _cache->getFont(fontId);
@@ -506,7 +506,11 @@ int16 GfxText32::getTextWidth(const uint index, uint length) const {
}
// Forward through any more unknown control character data
- while (length > 0 && currentChar != '|') {
+ while (length > 0 && *text != '|') {
+ ++text;
+ --length;
+ }
+ if (length > 0) {
++text;
--length;
}
@@ -514,8 +518,10 @@ int16 GfxText32::getTextWidth(const uint index, uint length) const {
width += font->getCharWidth(currentChar);
}
- currentChar = *text++;
- --length;
+ if (length > 0) {
+ currentChar = *text++;
+ --length;
+ }
}
return width;