spa: alsa: pcm: log_write(): don't use strcspn()

Do not use `strcspn()` because it assumes a null terminated string,
but the `fopencookie()` write callback receives a (ptr, length) pair.

So use `memchr()` instead to find the `\n`.
This commit is contained in:
Barnabás Pőcze 2026-05-06 21:45:44 +02:00 committed by Wim Taymans
parent bba43d4433
commit cfe9c7d6ca

View file

@ -716,16 +716,18 @@ int spa_alsa_parse_prop_params(struct state *state, struct spa_pod *params)
static ssize_t log_write(void *cookie, const char *buf, size_t size)
{
struct state *state = cookie;
int len;
for (size_t left = size; left > 0; ) {
len = strcspn(buf, "\n");
const char *end = memchr(buf, '\n', left);
size_t len = end ? end - buf : left;
if (len > 0)
spa_log_debug(state->log, "%.*s", (int)len, buf);
buf += len + 1;
left -= len + 1;
buf += len + !!end;
left -= len + !!end;
}
return size;
}