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.

(cherry picked from commit c5ca209f58)
This commit is contained in:
Wang King 2017-04-12 16:22:57 +08:00 committed by Cole Robinson
parent a7aacb742e
commit 679aa1901d

View File

@ -135,6 +135,8 @@ virSystemdAppendValidMachineName(virBufferPtr buf,
bool skip_dot = false;
for (; *name; name++) {
if (virBufferError(buf))
break;
if (strlen(virBufferCurrentContent(buf)) >= 64)
break;