diff --git a/src/util/virconf.c b/src/util/virconf.c index a85a3079cbf5382853de701746e3a0577a6fd14f..9840ca6c7d940b0a76004c9aa24df42f0682599e 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -287,14 +287,16 @@ virConfSaveValue(virBufferPtr buf, virConfValuePtr val) virBufferAsprintf(buf, "%llu", val->l); break; case VIR_CONF_STRING: - if (strchr(val->str, '\n') != NULL) { - virBufferAsprintf(buf, "\"\"\"%s\"\"\"", val->str); - } else if (strchr(val->str, '"') == NULL) { - virBufferAsprintf(buf, "\"%s\"", val->str); - } else if (strchr(val->str, '\'') == NULL) { - virBufferAsprintf(buf, "'%s'", val->str); - } else { - virBufferAsprintf(buf, "\"\"\"%s\"\"\"", val->str); + if (val->str) { + if (strchr(val->str, '\n') != NULL) { + virBufferAsprintf(buf, "\"\"\"%s\"\"\"", val->str); + } else if (strchr(val->str, '"') == NULL) { + virBufferAsprintf(buf, "\"%s\"", val->str); + } else if (strchr(val->str, '\'') == NULL) { + virBufferAsprintf(buf, "'%s'", val->str); + } else { + virBufferAsprintf(buf, "\"\"\"%s\"\"\"", val->str); + } } break; case VIR_CONF_LIST: {