diff --git a/.gnulib b/.gnulib index cdbf3d385a..d6397dde2e 160000 --- a/.gnulib +++ b/.gnulib @@ -1 +1 @@ -Subproject commit cdbf3d385a32ff904c96f20c26f3470bd8345248 +Subproject commit d6397dde2e127e246e3eeb5254a21f42cac783c8 diff --git a/src/util/virerror.c b/src/util/virerror.c index f198f27957..5f26d59777 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -366,19 +366,26 @@ virSetError(virErrorPtr newerr) * * One will need to free the result with virResetError() * - * Returns 0 if no error was found and the error code otherwise and -1 in case - * of parameter error. + * Returns error code or -1 in case of parameter error. */ int virCopyLastError(virErrorPtr to) { virErrorPtr err = virLastErrorObject(); + + if (!to) + return -1; + /* We can't guarantee caller has initialized it to zero */ memset(to, 0, sizeof(*to)); - if (err) + if (err) { virCopyError(err, to); - else + } else { virResetError(to); + to->code = VIR_ERR_NO_MEMORY; + to->domain = VIR_FROM_NONE; + to->level = VIR_ERR_ERROR; + } return to->code; }