diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-03 08:02:58 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-03 08:02:58 +0300 |
commit | 1fe2b10bc1a2def2af86390272907206f819b7ae (patch) | |
tree | 19ce9175a46d639d8b3a418fe4627728f45bcd29 | |
parent | dda4bc4184938014782f4f720de62196a12db697 (diff) |
GmDocument: Fixed a crash when selecting text
-rw-r--r-- | src/gmdocument.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 22f409a6..2f4c7972 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -2074,8 +2074,11 @@ iRangecc findLoc_GmRun(const iGmRun *d, iInt2 pos) { | |||
2074 | iRangecc loc; | 2074 | iRangecc loc; |
2075 | tryAdvanceNoWrap_Text(d->textParams.font, d->text, x, &loc.start); | 2075 | tryAdvanceNoWrap_Text(d->textParams.font, d->text, x, &loc.start); |
2076 | loc.end = loc.start; | 2076 | loc.end = loc.start; |
2077 | if (!contains_Range(&d->text, loc.start)) { | ||
2078 | return iNullRange; /* it's some other text */ | ||
2079 | } | ||
2077 | iChar ch; | 2080 | iChar ch; |
2078 | if (d->text.end != loc.start) { | 2081 | if (d->text.end && d->text.end != loc.start) { |
2079 | int chLen = decodeBytes_MultibyteChar(loc.start, d->text.end, &ch); | 2082 | int chLen = decodeBytes_MultibyteChar(loc.start, d->text.end, &ch); |
2080 | if (chLen > 0) { | 2083 | if (chLen > 0) { |
2081 | /* End after the character. */ | 2084 | /* End after the character. */ |