diff options
Diffstat (limited to 'libssh/messages.c')
-rw-r--r-- | libssh/messages.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libssh/messages.c b/libssh/messages.c index 126000b..3ecf4dd 100644 --- a/libssh/messages.c +++ b/libssh/messages.c @@ -43,18 +43,19 @@ static SSH_MESSAGE *message_new(SSH_SESSION *session){ - SSH_MESSAGE *msg=session->ssh_message; + SSH_MESSAGE *msg = session->ssh_message; + if (msg == NULL) { + msg = malloc(sizeof(SSH_MESSAGE)); if (msg == NULL) { - msg = malloc(sizeof(SSH_MESSAGE)); - if (msg == NULL) { - return NULL; - } - session->ssh_message = msg; + return NULL; } - memset(msg,0,sizeof (*msg)); - msg->session=session; - return msg; + session->ssh_message = msg; + } + memset(msg, 0, sizeof(*msg)); + msg->session = session; + + return msg; } static int handle_service_request(SSH_SESSION *session){ |