Skip to content

Commit

Permalink
Do not try to fetch messages for nonexistan channels.
Browse files Browse the repository at this point in the history
For some reason discord leaves read_state data about channels that no longer
exist in initial datastructure you get on connect. Trying to fetch backlog
messages from those channels resulted in a segfault, now those are ignored.
  • Loading branch information
sm00th committed Jan 14, 2016
1 parent ae894c5 commit c09d403
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/discord-handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ void discord_parse_message(struct im_connection *ic)
const char *lmsg = json_o_str(rsinfo, "last_message_id");
guint64 lm = g_ascii_strtoull(lmsg, NULL, 10);
channel_info *cinfo = get_channel_by_id(dd, channel_id, NULL);
if (cinfo->last_msg > lm) {
if (cinfo != NULL && cinfo->last_msg > lm) {
char *rlmsg = g_strdup_printf("%lu", cinfo->last_msg);
cinfo->last_msg = lm;
discord_http_get_backlog(ic, channel_id);
Expand Down

0 comments on commit c09d403

Please sign in to comment.