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.
This commit is contained in:
Wang King 2017-04-12 16:22:57 +08:00 committed by Peter Krempa
parent 1b1b045915
commit c5ca209f58
1 changed files with 2 additions and 0 deletions

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;