We only ever set "v2v_version" to non-NULL with pcre2_substring_get_bynumber(), as suggested by valgrind and then verified by code review.
Substrings extracted with this function cannot be released with free(); we must call pcre2_substring_free(). http://www.pcre.org/current/doc/html/pcre2_substring_get_bynumber.html http://www.pcre.org/current/doc/html/pcre2_substring_free.html The symptom of this bug is that the second click on the "Test Connection" causes free() to print: > free(): invalid pointer and then to call abort(). Signed-off-by: Laszlo Ersek <ler...@redhat.com> --- ssh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ssh.c b/ssh.c index 059f0e224cba..566121b172c5 100644 --- a/ssh.c +++ b/ssh.c @@ -765,7 +765,7 @@ test_connection (struct config *config) /* Clear any previous version information since we may be connecting * to a different server. */ - free (v2v_version); + pcre2_substring_free ((PCRE2_UCHAR *)v2v_version); v2v_version = NULL; /* Send 'virt-v2v --version' command and hope we get back a version string. @@ -788,7 +788,7 @@ test_connection (struct config *config) { 0 } }, match_data)) { case 100: /* Got version string. */ - free (v2v_version); + pcre2_substring_free ((PCRE2_UCHAR *)v2v_version); pcre2_substring_get_bynumber (match_data, 1, (PCRE2_UCHAR **) &v2v_version, &verlen); #if DEBUG_STDERR _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs