[Scummvm-git-logs] scummvm master -> 261ced8ca402446e2441dd6ce6a072a6660b0484
sev-
noreply at scummvm.org
Mon Nov 28 17:43:58 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
261ced8ca4 GRAPHICS: Fix getRowCol returning uninitialized variable nsx if there were no chunks for the chosen line.
Commit: 261ced8ca402446e2441dd6ce6a072a6660b0484
https://github.com/scummvm/scummvm/commit/261ced8ca402446e2441dd6ce6a072a6660b0484
Author: elasota (ejlasota at gmail.com)
Date: 2022-11-28T18:43:55+01:00
Commit Message:
GRAPHICS: Fix getRowCol returning uninitialized variable nsx if there were no chunks for the chosen line.
Changed paths:
graphics/macgui/mactext.cpp
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 40c3afae699..4f07c48edb3 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -2066,7 +2066,7 @@ int MacText::getAlignOffset(int row) {
}
void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
- int nsx, nsy, nrow, ncol;
+ int nsx = 0, nsy = 0, nrow = 0, ncol = 0;
if (y > _textMaxHeight) {
x = _surface->w;
@@ -2089,30 +2089,28 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
nsy = _textLines[nrow].y;
- ncol = 0;
+ if (_textLines[nrow].chunks.size() > 0) {
+ int alignOffset = getAlignOffset(nrow);
- int alignOffset = getAlignOffset(nrow);
+ int width = 0, pwidth = 0;
+ int mcol = 0, pmcol = 0;
- int width = 0, pwidth = 0;
- int mcol = 0, pmcol = 0;
- uint chunk;
- for (chunk = 0; chunk < _textLines[nrow].chunks.size(); chunk++) {
- pwidth = width;
- pmcol = mcol;
- if (!_textLines[nrow].chunks[chunk].text.empty()) {
- width += getStringWidth(_textLines[nrow].chunks[chunk], _textLines[nrow].chunks[chunk].text);
- mcol += _textLines[nrow].chunks[chunk].text.size();
- }
+ uint chunk;
+ for (chunk = 0; chunk < _textLines[nrow].chunks.size(); chunk++) {
+ pwidth = width;
+ pmcol = mcol;
+ if (!_textLines[nrow].chunks[chunk].text.empty()) {
+ width += getStringWidth(_textLines[nrow].chunks[chunk], _textLines[nrow].chunks[chunk].text);
+ mcol += _textLines[nrow].chunks[chunk].text.size();
+ }
- if (width + alignOffset > x)
- break;
- }
+ if (width + alignOffset > x)
+ break;
+ }
- if (chunk == _textLines[nrow].chunks.size())
- chunk--;
+ if (chunk == _textLines[nrow].chunks.size())
+ chunk--;
- // prevent out bounding error, because sometimes chunk.size() is 0, thus we don't have correct chunk number.
- if (chunk < _textLines[nrow].chunks.size()) {
Common::U32String str = _textLines[nrow].chunks[chunk].text;
ncol = mcol;
More information about the Scummvm-git-logs
mailing list