File libvirt-storage-Fix-memory-leak-with-regfree-reg-call.patch of Package libvirt
From 3eaf887efc66466dbe8c049811ceefd701716538 Mon Sep 17 00:00:00 2001
Message-Id: <3eaf887efc66466dbe8c049811ceefd701716538.1373271639.git.jdenemar@redhat.com>
From: John Ferlan <jferlan@redhat.com>
Date: Thu, 14 Mar 2013 11:19:06 -0400
Subject: [PATCH] storage: Fix memory leak with regfree(reg) call.
https://bugzilla.redhat.com/show_bug.cgi?id=906299
Although 'reg' was VIR_FREE()'d, a call to regfree(reg) was also required
to free resources alloc'd during regcomp.
(cherry picked from commit 71da3b66a8455faf8019effe3cf504a31f91f54a)
---
src/storage/storage_backend_logical.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index 7e141ad..2f3f5f1 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -208,13 +208,16 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool,
if (err != 0) {
char error[100];
regerror(err, reg, error, sizeof(error));
+ regfree(reg);
virReportError(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) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed volume extent devices value"));
goto cleanup;
--
1.8.2.1