Skip to content

Commit

Permalink
Fix crash when opening file with ANSI encoding on some systems (issue #…
Browse files Browse the repository at this point in the history
…97, introduced by aca3551).
  • Loading branch information
zufuliu committed Feb 6, 2019
1 parent bd3a266 commit ef8a551
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions scintilla/win32/PlatWin.cxx
Expand Up @@ -2106,28 +2106,28 @@ void SurfaceD2D::MeasureWidths(const Font &font_, std::string_view text, XYPOSIT
while (i < text.length()) {
positions[i++] = lastPos;
}
} else if (codePageText == 0) {

// One char per position
PLATFORM_ASSERT(text.length() == static_cast<size_t>(tbuf.tlen));
for (int kk = 0; kk < tbuf.tlen; kk++) {
positions[kk] = poses.buffer[kk];
}

} else {
const DBCSCharClassify *dbcs = DBCSCharClassify::Get(codePageText);
// May be one or two bytes per position
int ui = 0;
for (size_t i = 0; i < text.length() && ui < tbuf.tlen;) {
positions[i] = poses.buffer[ui];
if (dbcs->IsLeadByte(text[i])) {
positions[i + 1] = poses.buffer[ui];
i += 2;
} else {
i++;
}
if (dbcs) {
// May be one or two bytes per position
int ui = 0;
for (size_t i = 0; i < text.length() && ui < tbuf.tlen;) {
positions[i] = poses.buffer[ui];
if (dbcs->IsLeadByte(text[i])) {
positions[i + 1] = poses.buffer[ui];
i += 2;
} else {
i++;
}

ui++;
ui++;
}
} else {
// One char per position
PLATFORM_ASSERT(text.length() == static_cast<size_t>(tbuf.tlen));
for (int kk = 0; kk < tbuf.tlen; kk++) {
positions[kk] = poses.buffer[kk];
}
}
}
}
Expand Down

0 comments on commit ef8a551

Please sign in to comment.