From 081650eb67cf85e741d8e30babb9b7884b4fd36f 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() --- 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 a2e90273c5..48635df343 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -4966,7 +4966,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);