From bf9ea4ea71b6e7d6f96d4d69c661621518787df5 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 21 Jun 2020 22:40:17 +0200 Subject: [PATCH] shared: avoid copying empty string in nm_str_buf_append_printf() (cherry picked from commit 081650eb67cf85e741d8e30babb9b7884b4fd36f) --- shared/nm-glib-aux/nm-shared-utils.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index e7b9b043b4..23577a0d7c 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -4948,7 +4948,12 @@ nm_str_buf_append_printf (NMStrBuf *strbuf, nm_assert (l < G_MAXINT); if ((gsize) l >= available) { - gsize l2 = ((gsize) l) + 1u; + gsize l2; + + if (l == 0) + return; + + l2 = ((gsize) l) + 1u; nm_str_buf_maybe_expand (strbuf, l2, FALSE);