goto fail;
ret = snd_output_buffer_open(&output_log);
if (ret == 0) {
- char *buf;
+ char *buf, *p;
+ size_t sz;
PARA_INFO_LOG("dumping alsa configuration\n");
snd_pcm_dump(pad->handle, output_log);
- snd_output_buffer_string(output_log, &buf);
- for (;;) {
- char *p = strchr(buf, '\n');
- if (!p) /* omit last output line, it's empty */
+ sz = snd_output_buffer_string(output_log, &buf);
+ for (p = buf; p < buf + sz;) {
+ char *q = memchr(p, '\n', buf + sz - p);
+ if (!q)
break;
- *p = '\0';
- PARA_INFO_LOG("%s\n", buf);
- buf = p + 1;
+ *q = '\0';
+ PARA_INFO_LOG("%s\n", p);
+ p = q + 1;
}
snd_output_close(output_log);
}