dbus/sasl: fix UB with memchr(NULL, ...)
Apparently, memchr() is undefined if the first argument is NULL.
Furthermore, using -O3 gcc will actually use this information to
optimize code-paths around it, assuming the first argument passed to
memchr() cannot be NULL.
Fix this by never calling memchr() on NULL.
@@ -33,7 +33,8 @@ static void sasl_split(const char *input, size_t n_input,
*/
*cmd = input;
- *arg = memchr(input, ' ', n_input);
+ /* memchr(NULL, ..) is UB */
+ *arg = !n_input ? NULL : memchr(input, ' ', n_input);
if (*arg) {
*n_cmd = *arg - input;
