aboutsummaryrefslogtreecommitdiff
path: root/url-mode.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2025-01-31 12:10:58 +0000
committerDaniel Eklöf <daniel@ekloef.se>2025-02-05 12:35:17 +0000
commitab4426f9873eee6d83871f9bd03d2d64a5f862b8 (patch)
tree0f34d53d6c6acf6b3c4e7eb2999ee025257d624a /url-mode.c
parentfoot.ini+doc: add default value of url.regex (diff)
url-mode: regex: make sure there's always room for the NULL terminator
Diffstat (limited to 'url-mode.c')
-rw-r--r--url-mode.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/url-mode.c b/url-mode.c
index 9ba07d14..5b74771a 100644
--- a/url-mode.c
+++ b/url-mode.c
@@ -354,7 +354,8 @@ regex_detected(const struct terminal *term, enum url_action action, url_list_t *
for (size_t j = 0; j < char_len; j++) {
const size_t requires_size = vline->len + char_len;
- if (requires_size > vline->sz) {
+ /* Need to grow? Remember to save at least one byte for terminator */
+ if (vline->sz == 0 || requires_size > vline->sz - 1) {
const size_t new_size = requires_size * 2;
vline->utf8 = xreallocarray(vline->utf8, new_size, 1);
vline->map = xreallocarray(vline->map, new_size, sizeof(vline->map[0]));