Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cppcheck: [libdiscord.c:1289] -> [libdiscord.c:1284]: (warning) Either the condition 'if(guild)' is redundant or there is possible null pointer dereference: guild. #254

Closed
pabs3 opened this issue Aug 7, 2019 · 2 comments

Comments

@pabs3
Copy link
Contributor

commented Aug 7, 2019

Since commit 48e8287, cppcheck gives a warning related to the discord_replace_channel function. Seems like the guild variable needs to be checked for NULL before looking up the channels member of the variable:

[libdiscord.c:1289] -> [libdiscord.c:1284]: (warning) Either the condition 'if(guild)' is redundant or there is possible null pointer dereference: guild.
DiscordGuild *guild = ag->guild;
gchar *match_string = g_match_info_fetch(match, 0);
gchar *channel_id = g_match_info_fetch(match, 1);
gint64 channel_num = to_int(channel_id);
DiscordChannel *channel = g_hash_table_lookup_int64(guild->channels, channel_num);

if (channel) {
	/* TODO make this a clickable link */

	if (guild) {
		g_string_append_printf(result, "%s", discord_normalise_room_name(guild->name, channel->name));
	} else {
		g_string_append_printf(result, "#%s", channel->name);
	}
} else {
	g_string_append(result, match_string);
}
@pabs3

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2019

This issue is fixed in git master, not sure which commit fixed it.

@pabs3 pabs3 closed this Aug 30, 2019

@EionRobb

This comment has been minimized.

Copy link
Owner

commented Aug 30, 2019

Whoops, fixed in 41282a0

Sorry for not tagging this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.