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) {
if (!list_is_empty(bllines)) {
mylog(LOG_INFO, "backlogging: %s", bl); mylog(LOG_INFO, "backlogging: %s", bl);
write_lines(CONN(ic), bllines); write_lines(CONN(ic), bllines);
}
list_free(bllines); list_free(bllines);
} }
free(bl); free(bl);

View File

@ -1303,10 +1303,11 @@ 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. * This exception is cosmetic, but you want it.
* Most of the time, you get backlog from your own nick for * Most of the time, you get backlog from your own nick
* your mode changes only. * for your mode changes only.
* Hence opening a query just to say "end of backlog"... * Hence opening a query just to say "end of backlog"...
*/ */
if (strcmp(bl, cli_nick) != 0) { if (strcmp(bl, cli_nick) != 0) {
@ -1318,10 +1319,11 @@ list_t *backlog_lines(log_t *log, const char *bl, const char *cli_nick,
_irc_line_append(&l, "PRIVMSG"); _irc_line_append(&l, "PRIVMSG");
_irc_line_append(&l, dest); _irc_line_append(&l, dest);
_irc_line_append(&l, "End of backlog"); _irc_line_append(&l, "End of backlog");
if (ret) list_add_last(ret, irc_line_to_string(&l)); list_add_last(ret, irc_line_to_string(&l));
_irc_line_deinit(&l); _irc_line_deinit(&l);
} }
} }
}
return ret; return ret;
} }