From 363f35f076256597885f7e9aa87a740833086dbf Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 25 Nov 2024 12:32:24 +0000 Subject: [PATCH] Do not try to terminate an empty buffer. --- server-client.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server-client.c b/server-client.c index f1ea29c2..e640122f 100644 --- a/server-client.c +++ b/server-client.c @@ -3842,17 +3842,21 @@ server_client_print(struct client *c, int parse, struct evbuffer *evb) size_t size = EVBUFFER_LENGTH(evb); struct window_pane *wp; struct window_mode_entry *wme; - char *sanitized, *msg, *line; + char *sanitized, *msg, *line, empty = '\0'; if (!parse) { utf8_stravisx(&msg, data, size, VIS_OCTAL|VIS_CSTYLE|VIS_NOSLASH); - log_debug("%s: %s", __func__, msg); } else { - msg = EVBUFFER_DATA(evb); - if (msg[size - 1] != '\0') - evbuffer_add(evb, "", 1); + if (size == 0) + msg = ∅ + else { + msg = EVBUFFER_DATA(evb); + if (msg[size - 1] != '\0') + evbuffer_add(evb, "", 1); + } } + log_debug("%s: %s", __func__, msg); if (c == NULL) goto out;