Compare commits
2 commits
eaad08d462
...
c725dd7814
Author | SHA1 | Date | |
---|---|---|---|
c725dd7814 | |||
af0aa7904a |
2 changed files with 22 additions and 9 deletions
|
@ -404,6 +404,12 @@ static int api_hexchat_hook_print(lua_State *L)
|
||||||
lua_pushvalue(L, 2);
|
lua_pushvalue(L, 2);
|
||||||
ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
pri = luaL_optinteger(L, 3, HEXCHAT_PRI_NORM);
|
pri = luaL_optinteger(L, 3, HEXCHAT_PRI_NORM);
|
||||||
|
/* we rely on Close Context pri=INT_MIN for internal stuff. this avoids issues. */
|
||||||
|
if (pri == INT_MIN && strcmp(event, "Close Context"))
|
||||||
|
{
|
||||||
|
hexchat_print(ph, "Warning: Attempted to hook Close Context with priority INT_MIN. Adjusting to INT_MIN+1.");
|
||||||
|
pri = INT_MIN + 1;
|
||||||
|
}
|
||||||
info = g_new(hook_info, 1);
|
info = g_new(hook_info, 1);
|
||||||
info->state = L;
|
info->state = L;
|
||||||
info->ref = ref;
|
info->ref = ref;
|
||||||
|
|
|
@ -541,10 +541,13 @@ static int
|
||||||
plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[],
|
plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[],
|
||||||
hexchat_event_attrs *attrs, int type)
|
hexchat_event_attrs *attrs, int type)
|
||||||
{
|
{
|
||||||
|
/* fix segfault https://github.com/hexchat/hexchat/issues/2265 */
|
||||||
|
static int depth = 0;
|
||||||
GSList *list, *next;
|
GSList *list, *next;
|
||||||
hexchat_hook *hook;
|
hexchat_hook *hook;
|
||||||
int ret, eat = 0;
|
int ret, eat = 0;
|
||||||
|
|
||||||
|
depth++;
|
||||||
list = hook_list;
|
list = hook_list;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -590,18 +593,22 @@ plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[],
|
||||||
}
|
}
|
||||||
|
|
||||||
xit:
|
xit:
|
||||||
/* really remove deleted hooks now */
|
depth--;
|
||||||
list = hook_list;
|
if (!depth)
|
||||||
while (list)
|
|
||||||
{
|
{
|
||||||
hook = list->data;
|
/* really remove deleted hooks now */
|
||||||
next = list->next;
|
list = hook_list;
|
||||||
if (!hook || hook->type == HOOK_DELETED)
|
while (list)
|
||||||
{
|
{
|
||||||
hook_list = g_slist_remove (hook_list, hook);
|
hook = list->data;
|
||||||
g_free (hook);
|
next = list->next;
|
||||||
|
if (!hook || hook->type == HOOK_DELETED)
|
||||||
|
{
|
||||||
|
hook_list = g_slist_remove (hook_list, hook);
|
||||||
|
g_free (hook);
|
||||||
|
}
|
||||||
|
list = next;
|
||||||
}
|
}
|
||||||
list = next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return eat;
|
return eat;
|
||||||
|
|
Loading…
Add table
Reference in a new issue