Use-after-frees

Hi folks!

I tried clang-static-analyzer on irssi 1.1.1, it seems like it
finds some things. Here's a diff, but there might be more that you would
want to check, or choose to work differently.

(in special-vars.c, ret is commands->data sometime)

I hope it's not too much trouble if reported as a confidential bug.
Thanks.
This commit is contained in:
coypu@sdf.org 2018-08-11 22:28:14 +00:00 committed by ailin-nemui
commit 610ab2dafa
5 changed files with 8 additions and 5 deletions

View file

@ -289,8 +289,9 @@ void modules_deinit(void)
while (list != NULL) {
module_uniq_destroy(list->data);
g_free(list->data);
gconstpointer tmp = list->data;
list = g_slist_remove(list, list->data);
g_free(tmp);
}
g_hash_table_destroy(idlookup);

View file

@ -64,9 +64,10 @@ static void rawlog_add(RAWLOG_REC *rawlog, char *str)
if (rawlog->nlines < rawlog_lines || rawlog_lines <= 2)
rawlog->nlines++;
else {
g_free(rawlog->lines->data);
gconstpointer tmp = rawlog->lines->data;
rawlog->lines = g_slist_remove(rawlog->lines,
rawlog->lines->data);
g_free(tmp);
}
if (rawlog->logging) {

View file

@ -620,8 +620,8 @@ void eval_special_string(const char *cmd, const char *data,
/* FIXME: window item would need reference counting as well,
eg. "/EVAL win close;say hello" wouldn't work now.. */
g_free(ret);
commands = g_slist_remove(commands, commands->data);
g_free(ret);
}
g_free(orig);
}