Merge xchat r1525

Fixes possible crash
This commit is contained in:
TingPing 2013-07-20 18:00:19 -04:00
parent fe86c4900f
commit 13e9713b72

View File

@ -522,7 +522,7 @@ plugin_hook_find (GSList *list, int type, char *name)
while (list) while (list)
{ {
hook = list->data; hook = list->data;
if (hook->type == type) if (hook && hook->type == type)
{ {
if (g_ascii_strcasecmp (hook->name, name) == 0) if (g_ascii_strcasecmp (hook->name, name) == 0)
return list; return list;
@ -600,7 +600,7 @@ xit:
{ {
hook = list->data; hook = list->data;
next = list->next; next = list->next;
if (hook->type == HOOK_DELETED) if (!hook || hook->type == HOOK_DELETED)
{ {
hook_list = g_slist_remove (hook_list, hook); hook_list = g_slist_remove (hook_list, hook);
free (hook); free (hook);
@ -750,7 +750,7 @@ plugin_insert_hook (hexchat_hook *new_hook)
while (list) while (list)
{ {
hook = list->data; hook = list->data;
if (hook->type == new_hook->type && hook->pri <= new_hook->pri) if (hook && hook->type == new_hook->type && hook->pri <= new_hook->pri)
{ {
hook_list = g_slist_insert_before (hook_list, list, new_hook); hook_list = g_slist_insert_before (hook_list, list, new_hook);
return; return;
@ -828,7 +828,7 @@ plugin_command_list(GList *tmp_list)
while (list) while (list)
{ {
hook = list->data; hook = list->data;
if (hook->type == HOOK_COMMAND) if (hook && hook->type == HOOK_COMMAND)
tmp_list = g_list_prepend(tmp_list, hook->name); tmp_list = g_list_prepend(tmp_list, hook->name);
list = list->next; list = list->next;
} }
@ -846,7 +846,7 @@ plugin_command_foreach (session *sess, void *userdata,
while (list) while (list)
{ {
hook = list->data; hook = list->data;
if (hook->type == HOOK_COMMAND && hook->name[0]) if (hook && hook->type == HOOK_COMMAND && hook->name[0])
{ {
cb (sess, userdata, hook->name, hook->help_text); cb (sess, userdata, hook->name, hook->help_text);
} }