lagrange: fix crash when select image/text

Close: #33032
This commit is contained in:
Đoàn Trần Công Danh 2021-10-03 23:33:51 +07:00
parent 0ba4cf4582
commit e8d1d54b2c
2 changed files with 27 additions and 1 deletions

View file

@ -0,0 +1,26 @@
From 1fe2b10bc1a2def2af86390272907206f819b7ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= <jaakko.keranen@iki.fi>
Date: Sun, 3 Oct 2021 08:02:58 +0300
Subject: [PATCH] GmDocument: Fixed a crash when selecting text
---
src/gmdocument.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 22f409a..2f4c797 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -2074,8 +2074,11 @@ iRangecc findLoc_GmRun(const iGmRun *d, iInt2 pos) {
iRangecc loc;
tryAdvanceNoWrap_Text(d->textParams.font, d->text, x, &loc.start);
loc.end = loc.start;
+ if (!contains_Range(&d->text, loc.start)) {
+ return iNullRange; /* it's some other text */
+ }
iChar ch;
- if (d->text.end != loc.start) {
+ if (d->text.end && d->text.end != loc.start) {
int chLen = decodeBytes_MultibyteChar(loc.start, d->text.end, &ch);
if (chLen > 0) {
/* End after the character. */

View file

@ -1,7 +1,7 @@
# Template file for 'lagrange'
pkgname=lagrange
version=1.6.5
revision=1
revision=2
build_style=cmake
hostmakedepends="pkg-config"
makedepends="pcre-devel SDL2-devel openssl-devel zlib-devel libunistring-devel