libssh2_error() will free the previous error message if needed, but  
if the last error message needs to be freed, it is not being done  
so.  The following patches fix the problem for me.  In scp.c I null  
the error pointers after libssh2_error() to prevent double freeing.

Index: src/scp.c
===================================================================
RCS file: /cvsroot/libssh2/libssh2/src/scp.c,v
retrieving revision 1.16
diff -u -r1.16 scp.c
--- src/scp.c    5 Jul 2007 15:31:19 -0000       1.16
+++ src/scp.c    18 Jul 2007 18:00:48 -0000
@@ -188,6 +188,7 @@
                      }

                      libssh2_error(session,  
LIBSSH2_ERROR_SCP_PROTOCOL, session-
 >scpRecv_err_msg, 1);
+                    session->scpRecv_err_msg = NULL;
                      goto scp_recv_error;
                  }
@@ -640,6 +641,7 @@
              }

              libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,  
session->scpSend
_err_msg, 1);
+            session->scpSend_err_msg = NULL;
              goto scp_send_error;
          }
      }
Index: src/session.c
===================================================================
RCS file: /cvsroot/libssh2/libssh2/src/session.c,v
retrieving revision 1.47
diff -u -r1.47 session.c
--- src/session.c        22 Jun 2007 16:46:36 -0000      1.47
+++ src/session.c        18 Jul 2007 18:00:48 -0000
@@ -805,7 +805,18 @@
      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;

--

/"\   ASCII Ribbon Campaign  .
\ / - NO HTML/RTF in e-mail  .
  X  - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
                      http://www.FreeBSD.org     The Power to Serve
[EMAIL PROTECTED]  http://www.TheHousleys.net
---------------------------------------------------------------------
Fortune Not Found:
Abort, Retry, Ignore?




-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
libssh2-devel mailing list
libssh2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel

Reply via email to