diff --git a/Changelog b/Changelog index abc1bf4..2afe71c 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2.2] +* Fix crash when passing $mychannels() a non-existent window refnum. (caf) + * Remove dll_functions, dll_numeric, dll_commands, dll_variable, dll_ctcp, and dll_window variables from the module exports table. (caf) diff --git a/source/functions.c b/source/functions.c index a70c9b3..cf55e88 100644 --- a/source/functions.c +++ b/source/functions.c @@ -1886,18 +1886,28 @@ BUILT_IN_FUNCTION(function_curpos, input) RETURN_INT(current_window->screen->buffer_pos); } +/* $mychannels([window refnum]) + * + * Returns the list of channels associated with the server for the given window. + * + * Note that this differs from the EPIC4/EPIC5 function of the same name, which + * takes a server refnum instead. + */ BUILT_IN_FUNCTION(function_channels, input) { - long winnum; - Window *window = current_window; + Window *window = current_window; if (isdigit((unsigned char)*input)) { + long winnum; + GET_INT_ARG(winnum, input); window = get_window_by_refnum(winnum); } - if (window->server <= -1) + + if (!window) RETURN_EMPTY; + return create_channel_list(window); /* DON'T USE RETURN_STR HERE! */ }