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,
LINK(ic)->l_server->nick, hours);
if (bllines) {
mylog(LOG_INFO, "backlogging: %s", bl);
write_lines(CONN(ic), bllines);
if (!list_is_empty(bllines)) {
mylog(LOG_INFO, "backlogging: %s", bl);
write_lines(CONN(ic), bllines);
}
list_free(bllines);
}
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);
else
ret = log_backread_hours(log, bl, dest, hours);
/*
* This exception is cosmetic, but you want it.
* Most of the time, you get backlog from your own nick for
* your mode changes only.
* Hence opening a query just to say "end of backlog"...
*/
if (strcmp(bl, cli_nick) != 0) {
/* clean this up */
irc_line_init(&l);
l.origin = P_IRCMASK;
if (dest == cli_nick)
l.origin = (char *)bl;
_irc_line_append(&l, "PRIVMSG");
_irc_line_append(&l, dest);
_irc_line_append(&l, "End of backlog");
if (ret) list_add_last(ret, irc_line_to_string(&l));
_irc_line_deinit(&l);
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 your mode changes only.
* Hence opening a query just to say "end of backlog"...
*/
if (strcmp(bl, cli_nick) != 0) {
/* clean this up */
irc_line_init(&l);
l.origin = P_IRCMASK;
if (dest == cli_nick)
l.origin = (char *)bl;
_irc_line_append(&l, "PRIVMSG");
_irc_line_append(&l, dest);
_irc_line_append(&l, "End of backlog");
list_add_last(ret, irc_line_to_string(&l));
_irc_line_deinit(&l);
}
}
}
return ret;