* After setting the error to the error string from in the packet, set

the pointer to NULL so it can't be double freed.
* On session cleanup be sure to free the last error if it needs to be
This commit is contained in:
James Housley
2007-07-19 15:02:37 +00:00
parent 05c1164a67
commit 46f59112d9
2 changed files with 15 additions and 0 deletions

View File

@@ -805,7 +805,18 @@ LIBSSH2_API int libssh2_session_free(LIBSSH2_SESSION *session)
if (session->scpSend_command) {
LIBSSH2_FREE(session, session->scpSend_command);
}
if (session->scpRecv_err_msg) {
LIBSSH2_FREE(session, session->scpRecv_err_msg);
}
if (session->scpSend_err_msg) {
LIBSSH2_FREE(session, session->scpSend_err_msg);
}
/* Free the error message, if we ar supposed to */
if (session->err_msg && session->err_should_free) {
LIBSSH2_FREE(session, session->err_msg);
}
/* Cleanup any remaining packets */
while (session->packets.head) {
LIBSSH2_PACKET *tmp = session->packets.head;