From 21b704690b079e5de7caddcc74e84da1d80864bc Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 23 Aug 2013 14:10:51 -0700 Subject: [PATCH] Handle NULL conditions of display and terminal allocation. --- src/protocols/ssh/client.c | 7 +++++++ src/protocols/ssh/terminal.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/protocols/ssh/client.c b/src/protocols/ssh/client.c index 4a0e6457..79f55617 100644 --- a/src/protocols/ssh/client.c +++ b/src/protocols/ssh/client.c @@ -150,6 +150,13 @@ int guac_client_init(guac_client* client, int argc, char** argv) { client_data->font_name, client_data->font_size, client->info.optimal_width, client->info.optimal_height); + /* Fail if terminal init failed */ + if (client_data->term == NULL) { + guac_error = GUAC_STATUS_BAD_STATE; + guac_error_message = "Terminal initialization failed"; + return -1; + } + /* Set up I-bar pointer */ client_data->ibar_cursor = guac_ssh_create_ibar(client); diff --git a/src/protocols/ssh/terminal.c b/src/protocols/ssh/terminal.c index 2076a077..b983931a 100644 --- a/src/protocols/ssh/terminal.c +++ b/src/protocols/ssh/terminal.c @@ -119,6 +119,14 @@ guac_terminal* guac_terminal_create(guac_client* client, default_char.attributes.foreground, default_char.attributes.background); + /* Fail if display init failed */ + if (term->display == NULL) { + guac_error = GUAC_STATUS_BAD_STATE; + guac_error_message = "Display initialization failed"; + free(term); + return NULL; + } + /* Init terminal state */ term->current_attributes = default_char.attributes; term->default_char = default_char;