From: Jim Fehlig Date: Tue, 25 Aug 2009 21:54:18 +0000 (-0600) Subject: Fix sexpr2string() to handle empty list. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=8fd7eee90e8bd592722433e45b93dbb699052fd8;p=libvirt.git Fix sexpr2string() to handle empty list. S-expression containing empty lists, e.g. (cpus (() () () ())), was not being handled properly in sexpr2string() serialization. Emit an empty list when encountering NIL sexpr kind. --- diff --git a/src/sexpr.c b/src/sexpr.c index bc82d1fda8..81cb49f269 100644 --- a/src/sexpr.c +++ b/src/sexpr.c @@ -255,6 +255,10 @@ sexpr2string(const struct sexpr * sexpr, char *buffer, size_t n_buffer) ret += tmp; break; case SEXPR_NIL: + tmp = snprintf(buffer + ret, n_buffer - ret, "()"); + if (tmp == 0) + goto error; + ret += tmp; break; default: goto error;