Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parse_channelstring(): remove useless checks of g_strsplit() results.
1. !names[0] could only be true if tokens[i] is an empty string, but we already checked at the beginning of the for() loop that this is not the case. "(names[1] && names[2])" can also never be true, as g_strsplit(x, 2) returns a NULL-terminated pointer array with either one or a maximum of two non-NULL strings, so either names[1] or names[2] is always == NULL. Worst of all, in the case that the separator character "=" doesn't exist in the string, names[0] is the complete string, names[1] is == NULL and names[2] is undefined, so it's an error to even access it. (Current glib 2.64.1 seems to return an array with at least 3 allocated entries even if the result is only one string, but I can't find anything about that in the docs so better not rely on this behaviour). 2. Likewise, !range[0] could only be true if names[0] is an empty string. But we already asserted that it contains at least a dash character. So both range[0] and range[1] at least contain pointers to empty strings. g_strsplit(x, 2) returns a NULL-terminated pointer array with a maximum of (and in this case, exactly) two non-NULL strings, which means range[2] is always == NULL. As a result, "!range[0] || !range[1] || range[2]" can never be true.
- Loading branch information