Fix the $timer() scripting function.

This function never worked - function_timer() was creating a string but then
never throwing it away and returning a part of the argument instead, which
then caused a crash because it couldn't be freed later in the expression
parsing.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@472 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Kevin Easton
2013-11-16 03:17:13 +00:00
parent ffea653764
commit d03781f45b
2 changed files with 22 additions and 18 deletions

View File

@@ -1,5 +1,7 @@
[Changes 1.2c01]
* Fix the $timer() scripting function. (caf)
* Fix the /TKB (timed kickban) command. (caf)
* Rewrite termcap/terminfo detection logic in configure and include term.h

View File

@@ -454,24 +454,26 @@ static TimerList *get_timer (char *ref)
char *function_timer(char *n, char *args)
{
char *ref;
char *out = NULL;
TimerList *tmp;
ref = next_arg(args, &args);
if (ref && *ref && (tmp = get_timer(ref)))
{
char *ref = next_arg(args, &args);
TimerList *t = NULL;
double time_left;
struct timeval current;
char buf[40];
if (ref && *ref)
t = get_timer(ref);
if (!t)
return m_strdup(empty_string);
get_time(&current);
time_left = BX_time_diff(current, tmp->time);
time_left = BX_time_diff(current, t->time);
if (time_left < 0)
time_left = 0.0;
snprintf(buf, sizeof buf, "%0.3f", time_left);
malloc_sprintf(&out, "%s %d %d %d %d %s %s %s", tmp->ref, tmp->server, tmp->window, tmp->interval, tmp->events, buf, tmp->callback? "(internal callback)" : (tmp->command? tmp->command : ""), tmp->whom ? tmp->whom : empty_string );
return ref;
}
return m_strdup(empty_string);
return m_sprintf("%s %d %d %ld %d %0.3f %s%s", t->ref, t->server,
t->window, (long)t->interval, t->events, time_left,
t->callback ? "(internal callback) " : t->command,
t->whom ? t->whom : "");
}
/*