diff options
author | James Booth <boothj5@gmail.com> | 2012-10-24 02:18:20 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-10-24 02:18:20 +0100 |
commit | e49bea4d6bffd87b6631e84f03a35e47e5b35bd9 (patch) | |
tree | 22ec641ac74963a71c14096229744c63bb804bbf /src | |
parent | 8322c48d3e580e3f098b031554932924cde2fc00 (diff) | |
download | profani-tty-e49bea4d6bffd87b6631e84f03a35e47e5b35bd9.tar.gz |
Fixed possible NULL pointer references when offline
Diffstat (limited to 'src')
-rw-r--r-- | src/command.c | 24 | ||||
-rw-r--r-- | src/release.c | 9 | ||||
-rw-r--r-- | src/tinyurl.c | 8 |
3 files changed, 27 insertions, 14 deletions
diff --git a/src/command.c b/src/command.c index bedadfda..d22458a6 100644 --- a/src/command.c +++ b/src/command.c @@ -765,17 +765,23 @@ _cmd_tiny(const char * const inp, struct cmd_help_t help) free(url); } else if (win_in_chat()) { char *tiny = tinyurl_get(url); - char *recipient = win_get_recipient(); - jabber_send(tiny, recipient); + + if (tiny != NULL) { + char *recipient = win_get_recipient(); + jabber_send(tiny, recipient); - if (prefs_get_chlog()) { - const char *jid = jabber_get_jid(); - chat_log_chat(jid, recipient, tiny, OUT); - } + if (prefs_get_chlog()) { + const char *jid = jabber_get_jid(); + chat_log_chat(jid, recipient, tiny, OUT); + } - win_show_outgoing_msg("me", recipient, tiny); - free(recipient); - free(tiny); + win_show_outgoing_msg("me", recipient, tiny); + free(recipient); + free(tiny); + } else { + cons_bad_show("Couldn't get tinyurl."); + } + free(url); } else { cons_bad_command(inp); diff --git a/src/release.c b/src/release.c index fb08b8ba..f585e8fc 100644 --- a/src/release.c +++ b/src/release.c @@ -53,9 +53,12 @@ release_get_latest() curl_easy_perform(handle); curl_easy_cleanup(handle); - output.buffer[output.size++] = '\0'; - - return output.buffer; + if (output.buffer != NULL) { + output.buffer[output.size++] = '\0'; + return output.buffer; + } else { + return NULL; + } } static size_t diff --git a/src/tinyurl.c b/src/tinyurl.c index 9b572319..9ee64977 100644 --- a/src/tinyurl.c +++ b/src/tinyurl.c @@ -60,10 +60,14 @@ tinyurl_get(char *url) curl_easy_perform(handle); curl_easy_cleanup(handle); - output.buffer[output.size++] = '\0'; g_string_free(full_url, TRUE); - return output.buffer; + if (output.buffer != NULL) { + output.buffer[output.size++] = '\0'; + return output.buffer; + } else { + return NULL; + } } static size_t |