summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-23 07:08:57 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-23 07:08:57 +0000
commitd62a43ee9daba2d7c86850a1ffe1679c7c127b89 (patch)
tree56c53f18346230b0c7f6d0ac03f6a42cf81619ef
parent56e13b227fa0e217d0fdfce03f96f087d713fbd7 (diff)
downloadlibssh-d62a43ee9daba2d7c86850a1ffe1679c7c127b89.tar.gz
libssh-d62a43ee9daba2d7c86850a1ffe1679c7c127b89.tar.xz
libssh-d62a43ee9daba2d7c86850a1ffe1679c7c127b89.zip
Improve status_msg_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@586 7dcaeef0-15fb-0310-b436-a5af3365683c
-rw-r--r--libssh/sftp.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/libssh/sftp.c b/libssh/sftp.c
index fa795d0..7c6e3be 100644
--- a/libssh/sftp.c
+++ b/libssh/sftp.c
@@ -610,11 +610,7 @@ static STATUS_MESSAGE *parse_status_msg(SFTP_MESSAGE *msg){
status->errormsg = string_to_char(status->error);
status->langmsg = string_to_char(status->lang);
if (status->errormsg == NULL || status->langmsg == NULL) {
- string_free(status->error);
- string_free(status->lang);
- SAFE_FREE(status->errormsg);
- SAFE_FREE(status->langmsg);
- SAFE_FREE(status);
+ status_msg_free(status);
return NULL;
}
@@ -622,15 +618,15 @@ static STATUS_MESSAGE *parse_status_msg(SFTP_MESSAGE *msg){
}
static void status_msg_free(STATUS_MESSAGE *status){
- if(status->errormsg)
- free(status->errormsg);
- if(status->error)
- free(status->error);
- if(status->langmsg)
- free(status->langmsg);
- if(status->lang)
- free(status->lang);
- free(status);
+ if (status == NULL) {
+ return;
+ }
+
+ string_free(status->errormsg);
+ string_free(status->langmsg);
+ SAFE_FREE(status->error);
+ SAFE_FREE(status->lang);
+ SAFE_FREE(status);
}
static SFTP_FILE *parse_handle_msg(SFTP_MESSAGE *msg){