aboutsummaryrefslogtreecommitdiff
path: root/view.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-02-12 17:32:33 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-02-12 17:32:33 +0100
commitc8e153c124fb606aed507ba99eda424048e24112 (patch)
treeef3fb8df33b7e50c5ee3a5164dbdd642065adc57 /view.c
parent99d1964a6c2ae7e826b00128d5a201ae64d5a97f (diff)
downloadvis-c8e153c124fb606aed507ba99eda424048e24112.tar.gz
vis-c8e153c124fb606aed507ba99eda424048e24112.tar.xz
view: improve handling of long sequences of combining characters
They will still not be displayed correctly, but at least they should no longer cause memory errors.
Diffstat (limited to 'view.c')
-rw-r--r--view.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/view.c b/view.c
index e7dae36..d681656 100644
--- a/view.c
+++ b/view.c
@@ -370,6 +370,8 @@ void view_draw(View *view) {
/* NUL byte encountered, store it and continue */
cell = (Cell){ .data = "\x00", .len = 1, .width = 2 };
} else {
+ if (len >= sizeof(cell.data))
+ len = sizeof(cell.data)-1;
for (size_t i = 0; i < len; i++)
cell.data[i] = cur[i];
cell.data[len] = '\0';
@@ -384,7 +386,7 @@ void view_draw(View *view) {
cell = (Cell){ .data = "\n", .len = 2, .width = 1 };
}
- if (cell.width == 0 && prev_cell.len + cell.len < sizeof(cell.len)) {
+ if (cell.width == 0 && prev_cell.len + cell.len < sizeof(cell.data)) {
prev_cell.len += cell.len;
strcat(prev_cell.data, cell.data);
} else {