diff options
author | James Booth <boothj5@gmail.com> | 2012-07-29 21:32:04 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-07-29 21:32:04 +0100 |
commit | fe12352b57517d4346f3ca391b525894e5a61c7a (patch) | |
tree | 0a2056c6c32870e3696e9166d4f7f2f4234f7018 /src | |
parent | 8f983c0484895c8aafc064e2a08188dd6dca4fb8 (diff) | |
download | profani-tty-fe12352b57517d4346f3ca391b525894e5a61c7a.tar.gz |
Fixed bug in tinyurl
Diffstat (limited to 'src')
-rw-r--r-- | src/command.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/command.c b/src/command.c index 3bddc895..30c76b12 100644 --- a/src/command.c +++ b/src/command.c @@ -283,23 +283,29 @@ _cmd_msg(const char * const inp) static gboolean _cmd_tiny(const char * const inp) { - char *url = strndup(inp+6, strlen(inp)-6); - - if (!tinyurl_valid(url)) { - GString *error = g_string_new("/tiny, badly formed URL: "); - g_string_append(error, url); - cons_bad_show(error->str); - g_string_free(error, TRUE); - } else if (win_in_chat()) { - char *tiny = tinyurl_get(url); - char *recipient = win_get_recipient(); - jabber_send(tiny, recipient); - win_show_outgoing_msg("me", recipient, tiny); - free(recipient); - free(tiny); - free(url); + if (strlen(inp) > 6) { + char *url = strndup(inp+6, strlen(inp)-6); + + if (!tinyurl_valid(url)) { + GString *error = g_string_new("/tiny, badly formed URL: "); + g_string_append(error, url); + cons_bad_show(error->str); + g_string_free(error, TRUE); + free(url); + } else if (win_in_chat()) { + char *tiny = tinyurl_get(url); + char *recipient = win_get_recipient(); + jabber_send(tiny, recipient); + win_show_outgoing_msg("me", recipient, tiny); + free(recipient); + free(tiny); + free(url); + } else { + cons_bad_command(inp); + free(url); + } } else { - cons_bad_command(inp); + cons_show("usage: /tiny url"); } return TRUE; |