From: Luca Tettamanti Date: Thu, 25 Apr 2013 19:44:30 +0000 (+0200) Subject: storage: Need to also VIR_FREE(reg) X-Git-Tag: v0.9.12.1~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3afbdfc3c496041eeef381d787aec8f48330cff6;p=thirdparty%2Flibvirt.git storage: Need to also VIR_FREE(reg) Commit-id 'afc4631b' added the regfree(reg) to free resources alloc'd during regcomp; however, reg still needed to be VIR_FREE()'d. The call to regfree() also didn't account for possible NULL value. Reformatted the call to be closer to usage. (cherry picked from commit 71da3b66a8455faf8019effe3cf504a31f91f54a) Backported to 0.9.12 with afc4631b and its revert skipped. Signed-off-by: Luca Tettamanti --- diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 9a91dd9a74..7abb17b698 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -204,13 +204,16 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool, if (err != 0) { char error[100]; regerror(err, reg, error, sizeof(error)); + regfree(reg); virStorageReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to compile regex %s"), error); goto cleanup; } - if (regexec(reg, groups[3], nvars, vars, 0) != 0) { + err = regexec(reg, groups[3], nvars, vars, 0); + regfree(reg); + if (err != 0) { virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed volume extent devices value")); goto cleanup;