summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-09-21 19:38:50 +0100
committerRichard W.M. Jones <rjones@redhat.com>2010-09-21 19:51:22 +0100
commite7f62742b6141fd19444fc0e191281777cd966f9 (patch)
tree6c04bfc48aa9269575621db2a8dac4e226dc5360
parent6d276dae8d1bbb54d8708c94d23879d39f5fd4a3 (diff)
downloadlibguestfs-e7f62742b6141fd19444fc0e191281777cd966f9.tar.gz
libguestfs-e7f62742b6141fd19444fc0e191281777cd966f9.tar.xz
libguestfs-e7f62742b6141fd19444fc0e191281777cd966f9.zip
leak: Free PCRE regexps when library is unloaded.
The compiled PCRE regexps used for inspection were being leaked when the library was unloaded. (Found by valgrind).
-rw-r--r--src/inspect.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/inspect.c b/src/inspect.c
index 11a53740..bce0fd6e 100644
--- a/src/inspect.c
+++ b/src/inspect.c
@@ -57,6 +57,8 @@ static pcre *re_xdev;
static pcre *re_windows_version;
static void compile_regexps (void) __attribute__((constructor));
+static void free_regexps (void) __attribute__((destructor));
+
static void
compile_regexps (void)
{
@@ -88,6 +90,22 @@ compile_regexps (void)
COMPILE (re_windows_version, "^(\\d+)\\.(\\d+)", 0);
}
+static void
+free_regexps (void)
+{
+ pcre_free (re_file_elf);
+ pcre_free (re_file_win64);
+ pcre_free (re_elf_ppc64);
+ pcre_free (re_fedora);
+ pcre_free (re_rhel_old);
+ pcre_free (re_rhel);
+ pcre_free (re_rhel_no_minor);
+ pcre_free (re_debian);
+ pcre_free (re_aug_seq);
+ pcre_free (re_xdev);
+ pcre_free (re_windows_version);
+}
+
/* Match a regular expression which contains no captures. Returns
* true if it matches or false if it doesn't.
*/