mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-09 05:58:26 +02:00
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:
parent
bba43d4433
commit
cfe9c7d6ca
1 changed files with 6 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue