
On 05/20/2013 07:55 PM, Michal Privoznik wrote:
--- src/xenxs/xen_sxpr.c | 200 ++++++++++++++++++++++----------------------------- src/xenxs/xen_xm.c | 91 +++++++++++------------ 2 files changed, 125 insertions(+), 166 deletions(-)
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c index 9a76d04..aa99a61 100644 --- a/src/xenxs/xen_sxpr.c +++ b/src/xenxs/xen_sxpr.c @@ -238,18 +236,14 @@ xenParseSxprChar(const char *value, }
if (offset != value && - (def->source.data.tcp.host = strndup(value, - offset - value)) == NULL) - goto no_memory; + VIR_STRNDUP(def->source.data.tcp.host, value, offset - value) < 0) + goto error;
offset2 = strchr(offset, ','); - if (offset2 == NULL) - def->source.data.tcp.service = strdup(offset+1); - else - def->source.data.tcp.service = strndup(offset+1, - offset2-(offset+1)); - if (def->source.data.tcp.service == NULL) - goto no_memory; + if ((offset && VIR_STRNDUP(def->source.data.tcp.service, + offset + 1, offset2 - offset - 1) < 0) || + (!offset && VIR_STRDUP(def->source.data.tcp.service, offset + 1) < 0)) + goto error;
Change offset to offset2 at the beginning of the condition. Or you could do it with just one VIR_STRNDUP call: offset++; if (VIR_STRNDUP(def->source.data.tcp.service, offset, offset2 ? offset2 - offset : strlen(offset)) < 0) goto error;
if (offset2 && strstr(offset2, ",server")) def->source.data.tcp.listen = true;
ACK Jan