mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-08-01 14:56:20 +00:00
_cmd_tiny: fix possible NULL pointer dereference
Check 'url' for NULL and move free(url) out of if-else structure
This commit is contained in:
@@ -753,6 +753,10 @@ _cmd_tiny(const char * const inp, struct cmd_help_t help)
|
||||
{
|
||||
if (strlen(inp) > 6) {
|
||||
char *url = strndup(inp+6, strlen(inp)-6);
|
||||
if (url == NULL) {
|
||||
log_error("Not enough memory.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!tinyurl_valid(url)) {
|
||||
GString *error = g_string_new("/tiny, badly formed URL: ");
|
||||
@@ -762,7 +766,6 @@ _cmd_tiny(const char * const inp, struct cmd_help_t help)
|
||||
win_bad_show(error->str);
|
||||
}
|
||||
g_string_free(error, TRUE);
|
||||
free(url);
|
||||
} else if (win_in_chat()) {
|
||||
char *tiny = tinyurl_get(url);
|
||||
|
||||
@@ -781,12 +784,10 @@ _cmd_tiny(const char * const inp, struct cmd_help_t help)
|
||||
} else {
|
||||
cons_bad_show("Couldn't get tinyurl.");
|
||||
}
|
||||
|
||||
free(url);
|
||||
} else {
|
||||
cons_bad_command(inp);
|
||||
free(url);
|
||||
}
|
||||
free(url);
|
||||
} else {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user