Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
rsm
Commits
27de0ad0
Commit
27de0ad0
authored
May 06, 2020
by
LEFEBVREJP email
Browse files
#2
. Cleaning memory defects.
parent
3d94b5c0
Pipeline
#100419
failed with stages
in 5 minutes and 17 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
rsmcore/session.cc
View file @
27de0ad0
...
...
@@ -246,7 +246,10 @@ ssize_t SFTPFile::write(QString str)
// success
QString
SFTPFile
::
read
(
size_t
nBytes
)
{
char
*
buf
=
new
char
[
nBytes
+
1
];
if
(
nBytes
==
0
)
return
QString
();
char
*
buf
=
new
char
[
nBytes
+
1
];
// initialize buff
memset
(
&
buf
[
0
],
0
,
nBytes
);
buf
[
nBytes
]
=
'\0'
;
ssize_t
nBytesRead
=
sftp_read
(
p
->
file
,
buf
,
nBytes
);
if
(
nBytesRead
<
0
)
...
...
@@ -352,6 +355,9 @@ SFTPAttributes* SFTPDir::next()
retVal
->
extended_data
=
QString
(
ssh_string_get_char
(
sftpResult
->
extended_data
));
// release memory
sftp_attributes_free
(
sftpResult
);
return
retVal
;
}
...
...
@@ -382,7 +388,6 @@ class SessionImpl
if
(
session
!=
nullptr
)
{
ssh_free
(
session
);
ssh_finalize
();
}
}
};
// class SessionImpl
...
...
@@ -410,18 +415,16 @@ QString Session::host() const
{
// This may not be necessary
assert_ssh_session
(
p
->
session
,
"host() -- Session is not allocated."
);
char
*
host_name
;
char
*
host_name
=
nullptr
;
QString
host
;
int
rv
=
ssh_options_get
(
p
->
session
,
SSH_OPTIONS_HOST
,
&
host_name
);
if
(
rv
==
SSH_OK
)
{
QString
host
=
host_name
;
delete
host_name
;
return
host
;
}
else
{
return
QString
(
""
);
host
=
host_name
;
}
if
(
host_name
!=
nullptr
)
ssh_string_free_char
(
host_name
);
return
host
;
}
void
Session
::
setLogVerbosity
(
SessionVerbosity
level
)
{
...
...
@@ -445,18 +448,15 @@ QString Session::user() const
{
// This may not be necessary
assert_ssh_session
(
p
->
session
,
"user() -- Session is not allocated."
);
char
*
user_name
;
char
*
user_name
=
nullptr
;
QString
user
;
int
rv
=
ssh_options_get
(
p
->
session
,
SSH_OPTIONS_USER
,
&
user_name
);
if
(
rv
==
SSH_OK
)
{
QString
user
=
user_name
;
delete
user_name
;
return
user
;
}
else
{
return
QString
(
""
);
user
=
user_name
;
}
if
(
user_name
!=
nullptr
)
ssh_string_free_char
(
user_name
);
return
user
;
}
void
Session
::
setProxyCommand
(
QString
command
)
...
...
@@ -479,6 +479,7 @@ bool Session::connect()
radix_tagged_line
(
"Attempting connection."
);
// attempt a connection
int
rc
=
ssh_connect
(
p
->
session
);
radix_tagged_line
(
"
\t
Connect return: "
<<
rc
);
return
(
rc
==
SSH_OK
);
}
}
...
...
@@ -498,7 +499,7 @@ bool Session::disconnect()
{
assert_ssh_session
(
p
->
session
,
"disconnect() -- Session is not allocated."
);
radix_tagged_line
(
"disconnect()"
);
if
(
ssh_is_c
onnected
(
p
->
session
)
!=
0
)
if
(
isC
onnected
(
)
)
{
radix_tagged_line
(
"Disconnecting session."
);
ssh_disconnect
(
p
->
session
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment