free_last_match() frees the memory of the match passed as argument, so
accessing it is not possible after free_last_match(). Since all we
need is the return code, save it locally for later usage.
---
common/mlpcre/pcre-c.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/mlpcre/pcre-c.c b/common/mlpcre/pcre-c.c
index da982025f..0762a8341 100644
--- a/common/mlpcre/pcre-c.c
+++ b/common/mlpcre/pcre-c.c
@@ -207,8 +207,9 @@ guestfs_int_pcre_matches (value rev, value strv)
m->r = pcre_exec (re, NULL, m->subject, len, 0, 0, m->vec, veclen);
if (m->r < 0 && m->r != PCRE_ERROR_NOMATCH) {
+ int ret = m->r;
free_last_match (m);
- raise_pcre_error ("pcre_exec", m->r);
+ raise_pcre_error ("pcre_exec", ret);
}
/* This error would indicate that pcre_exec ran out of space in the
--
2.14.3