diff --git a/src/util/buf.c b/src/util/buf.c index c802aa2c61e63072d922b3d0407bd2f10c9aa450..9681635caa0ef54af8c2a6c7401c9dede1351744 100644 --- a/src/util/buf.c +++ b/src/util/buf.c @@ -318,6 +318,12 @@ virBufferEscapeString(const virBufferPtr buf, const char *format, const char *st } *out = 0; + if ((buf->use >= buf->size) && + virBufferGrow(buf, 100) < 0) { + VIR_FREE(escaped); + return; + } + size = buf->size - buf->use - 1; while (((count = snprintf(&buf->content[buf->use], size, format, (char *)escaped)) < 0) || (count >= size - 1)) {