Commit da03c8eb authored by Lefebvre, Jordan's avatar Lefebvre, Jordan
Browse files

Fixing double free of session.

parent 052b45f3
......@@ -35,6 +35,7 @@ class SessionWorkerImpl
if (session != nullptr)
{
ssh_free(session);
ssh_finalize();
}
}
};
......@@ -107,8 +108,6 @@ void SessionWorker::disconnect()
{
radix_tagged_line("Disconnecting session.");
ssh_disconnect(p->session);
ssh_free(p->session);
ssh_finalize();
}
}
......@@ -264,6 +263,7 @@ void SessionWorker::requestExec(QString command)
{
assert_ssh_session(p->session, "request_exec() -- Session is not allocated.");
radix_tagged_line("requestExec(" << command.toStdString() << ")");
char buffer[256];
// clear any previous buffer
p->output_buffer.clear();
......@@ -294,10 +294,10 @@ void SessionWorker::requestExec(QString command)
{
p->output_buffer.append(buffer, nbytes);
emit execOutputReady();
radix(nbytes);
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
}
radix_tagged_line();
radix_tagged_line("nbytes=" << nbytes);
radix_tagged_line("Finished reading response\n" << p->output_buffer.data());
if (nbytes == 0)
{
......
......@@ -5,13 +5,14 @@
using namespace rsm;
TEST(RSM, Session)
{
SessionWorker session("warroom4");
session.setLogVerbosity(SessionWorker::Verbosity::Functions);
SessionWorker session("nfecc");
session.setLogVerbosity(SessionWorker::Verbosity::None);
session.setPort(22);
session.setUser("jap");
session.connect(); // 1) hand-shake with host
session.verifyKnownHost(); // 2) verify host is known/acceptable
session.authenticate(); // 3) process authentication
session.requestExec("ls -la");
session.requestExec("ls modulefiles");
session.disconnect();
}
\ No newline at end of file
Markdown is supported
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