session BUGFIX incorrect var use
diff --git a/src/session.c b/src/session.c
index 7f48ebe..5ddc607 100644
--- a/src/session.c
+++ b/src/session.c
@@ -811,10 +811,10 @@
                     session->ti.libssh.next = siter->ti.libssh.next;
 
                     /* free starting SSH NETCONF session (channel will be freed in ssh_free()) */
-                    free(session->username);
-                    free(session->host);
-                    if (!(session->flags & NC_SESSION_SHAREDCTX)) {
-                        ly_ctx_destroy((struct ly_ctx *)session->ctx);
+                    free(siter->username);
+                    free(siter->host);
+                    if (!(siter->flags & NC_SESSION_SHAREDCTX)) {
+                        ly_ctx_destroy((struct ly_ctx *)siter->ctx);
                     }
 
                     free(siter);