Commit f3aff699 authored by Bill King's avatar Bill King
Browse files

Fixes resource leak if lock not acquired.

parent ce448b3e
...@@ -301,9 +301,9 @@ int ne7ssh::connectWithPassword (const char *host, const int port, ...@@ -301,9 +301,9 @@ int ne7ssh::connectWithPassword (const char *host, const int port,
uint32 currentRecord, z; uint32 currentRecord, z;
uint32 channelID; uint32 channelID;
ne7ssh_connection* con = new ne7ssh_connection (callbackFunc, callbackArg);
if (!lock()) return -1; if (!lock()) return -1;
ne7ssh_connection* con = new ne7ssh_connection (callbackFunc, callbackArg);
if (!conCount) connections = (ne7ssh_connection**) malloc (sizeof (ne7ssh_connection*)); if (!conCount) connections = (ne7ssh_connection**) malloc (sizeof (ne7ssh_connection*));
else connections = (ne7ssh_connection**) realloc (connections, sizeof (ne7ssh_connection*) * (conCount + 1)); else connections = (ne7ssh_connection**) realloc (connections, sizeof (ne7ssh_connection*) * (conCount + 1));
connections[conCount++] = con; connections[conCount++] = con;
...@@ -354,8 +354,8 @@ int ne7ssh::connectWithKey (const char* host, const int port, ...@@ -354,8 +354,8 @@ int ne7ssh::connectWithKey (const char* host, const int port,
uint32 currentRecord, z; uint32 currentRecord, z;
uint32 channelID; uint32 channelID;
ne7ssh_connection* con = new ne7ssh_connection (callbackFunc, callbackArg);
if (!lock()) return -1; if (!lock()) return -1;
ne7ssh_connection* con = new ne7ssh_connection (callbackFunc, callbackArg);
if (!conCount) connections = (ne7ssh_connection**) malloc (sizeof (ne7ssh_connection*) * (conCount + 1)); if (!conCount) connections = (ne7ssh_connection**) malloc (sizeof (ne7ssh_connection*) * (conCount + 1));
else connections = (ne7ssh_connection**) realloc (connections, sizeof (ne7ssh_connection*) * (conCount + 1)); else connections = (ne7ssh_connection**) realloc (connections, sizeof (ne7ssh_connection*) * (conCount + 1));
connections[conCount++] = con; connections[conCount++] = con;
......
...@@ -137,7 +137,11 @@ bool Ne7sshError::push (int32 channel, const char* format, ...) ...@@ -137,7 +137,11 @@ bool Ne7sshError::push (int32 channel, const char* format, ...)
va_end (args); va_end (args);
if (!lock()) return false; if (!lock())
{
free(errStr);
return false;
}
if (!memberCount) if (!memberCount)
{ {
ErrorBuffer = (Error**) malloc (sizeof(Error*)); ErrorBuffer = (Error**) malloc (sizeof(Error*));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment