aboutsummaryrefslogtreecommitdiff
path: root/text.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2020-10-20 15:32:16 +0200
committerMarc André Tanner <mat@brain-dump.org>2020-10-30 20:39:15 +0100
commit87dacc4092305b0bc81165712aa0027c4b0063d1 (patch)
treeef35e31fa585f97b127b0f409fd793828f6d90f3 /text.c
parent3fe8d2ecb9fafc67b2731419a47a1b467f381dae (diff)
downloadvis-87dacc4092305b0bc81165712aa0027c4b0063d1.tar.gz
vis-87dacc4092305b0bc81165712aa0027c4b0063d1.tar.xz
text: avoid invalid pointer arithmetic
Diffstat (limited to 'text.c')
-rw-r--r--text.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/text.c b/text.c
index 95d0ad8..51cb442 100644
--- a/text.c
+++ b/text.c
@@ -803,8 +803,8 @@ static bool iterator_init(Iterator *it, size_t pos, Piece *p, size_t off) {
.pos = pos,
.piece = p,
.start = p ? p->data : NULL,
- .end = p ? p->data + p->len : NULL,
- .text = p ? p->data + off : NULL,
+ .end = p && p->data ? p->data + p->len : NULL,
+ .text = p && p->data ? p->data + off : NULL,
};
*it = iter;
return text_iterator_valid(it);