diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 76934c7c0b..48ef914c70 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -108,26 +108,12 @@ struct _virNetLibsshSession { size_t bufStart; }; -static void -virNetLibsshSessionAuthMethodsFree(virNetLibsshSessionPtr sess) -{ - size_t i; - - for (i = 0; i < sess->nauths; i++) { - virSecureEraseString(sess->auths[i]->password); - g_free(sess->auths[i]->password); - VIR_FREE(sess->auths[i]->filename); - VIR_FREE(sess->auths[i]); - } - - VIR_FREE(sess->auths); - sess->nauths = 0; -} - static void virNetLibsshSessionDispose(void *obj) { virNetLibsshSessionPtr sess = obj; + size_t i; + VIR_DEBUG("sess=0x%p", sess); if (!sess) @@ -144,7 +130,14 @@ virNetLibsshSessionDispose(void *obj) ssh_free(sess->session); } - virNetLibsshSessionAuthMethodsFree(sess); + for (i = 0; i < sess->nauths; i++) { + virSecureEraseString(sess->auths[i]->password); + VIR_FREE(sess->auths[i]->password); + VIR_FREE(sess->auths[i]->filename); + VIR_FREE(sess->auths[i]); + } + + VIR_FREE(sess->auths); VIR_FREE(sess->channelCommand); VIR_FREE(sess->hostname);