From c5ca209f5848c68334c06cb2955758bd486fd149 Mon Sep 17 00:00:00 2001 From: Wang King Date: Wed, 12 Apr 2017 16:22:57 +0800 Subject: [PATCH] util: systemd: Don't strlen a possibly NULL string Coverity complains about virBufferCurrentContent might be return null when calling strlen, so check virBufferError first before calling strlen. --- src/util/virsystemd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index ceb1c1a958..83737a2c6f 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -135,6 +135,8 @@ virSystemdAppendValidMachineName(virBufferPtr buf, bool skip_dot = false; for (; *name; name++) { + if (virBufferError(buf)) + break; if (strlen(virBufferCurrentContent(buf)) >= 64) break;