Better check for backread returning NULL

This commit is contained in:
Arnaud Cornet 2009-01-22 11:24:44 +01:00
parent 43fe81e114
commit 23b6ec4492
2 changed files with 23 additions and 19 deletions

View File

@ -679,8 +679,10 @@ void irc_cli_backlog(struct link_client *ic, int hours)
bllines = backlog_lines(LINK(ic)->log, bl, bllines = backlog_lines(LINK(ic)->log, bl,
LINK(ic)->l_server->nick, hours); LINK(ic)->l_server->nick, hours);
if (bllines) { if (bllines) {
mylog(LOG_INFO, "backlogging: %s", bl); if (!list_is_empty(bllines)) {
write_lines(CONN(ic), bllines); mylog(LOG_INFO, "backlogging: %s", bl);
write_lines(CONN(ic), bllines);
}
list_free(bllines); list_free(bllines);
} }
free(bl); free(bl);

View File

@ -1303,23 +1303,25 @@ list_t *backlog_lines(log_t *log, const char *bl, const char *cli_nick,
ret = log_backread(log, bl, dest); ret = log_backread(log, bl, dest);
else else
ret = log_backread_hours(log, bl, dest, hours); ret = log_backread_hours(log, bl, dest, hours);
/* if (ret && !list_is_empty(ret)) {
* This exception is cosmetic, but you want it. /*
* Most of the time, you get backlog from your own nick for * This exception is cosmetic, but you want it.
* your mode changes only. * Most of the time, you get backlog from your own nick
* Hence opening a query just to say "end of backlog"... * for your mode changes only.
*/ * Hence opening a query just to say "end of backlog"...
if (strcmp(bl, cli_nick) != 0) { */
/* clean this up */ if (strcmp(bl, cli_nick) != 0) {
irc_line_init(&l); /* clean this up */
l.origin = P_IRCMASK; irc_line_init(&l);
if (dest == cli_nick) l.origin = P_IRCMASK;
l.origin = (char *)bl; if (dest == cli_nick)
_irc_line_append(&l, "PRIVMSG"); l.origin = (char *)bl;
_irc_line_append(&l, dest); _irc_line_append(&l, "PRIVMSG");
_irc_line_append(&l, "End of backlog"); _irc_line_append(&l, dest);
if (ret) list_add_last(ret, irc_line_to_string(&l)); _irc_line_append(&l, "End of backlog");
_irc_line_deinit(&l); list_add_last(ret, irc_line_to_string(&l));
_irc_line_deinit(&l);
}
} }
} }
return ret; return ret;