From: Tomohiro IKEDA Date: Tue, 14 Jun 2022 23:45:19 +0000 (+0900) Subject: pcm: dmix - Add error handler for `fgets` X-Git-Tag: v1.2.7.1~2 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=ff0db96bbc16440f6f0558f797bcc31e89f6df9e;p=alsa-lib.git pcm: dmix - Add error handler for `fgets` Fixes: https://github.com/alsa-project/alsa-lib/pull/238 Signed-off-by: Tomohiro IKEDA Signed-off-by: Jaroslav Kysela --- diff --git a/src/pcm/pcm_dmix_i386.c b/src/pcm/pcm_dmix_i386.c index 82a91c5c..ea55d8ec 100644 --- a/src/pcm/pcm_dmix_i386.c +++ b/src/pcm/pcm_dmix_i386.c @@ -104,8 +104,7 @@ static void mix_select_callbacks(snd_pcm_direct_t *dmix) /* try to determine the capabilities of the CPU */ in = fopen("/proc/cpuinfo", "r"); if (in) { - while (!feof(in)) { - fgets(line, sizeof(line), in); + while (!feof(in) && (fgets(line, sizeof(line), in) != NULL)) { if (!strncmp(line, "processor", 9)) smp++; else if (!strncmp(line, "flags", 5)) { diff --git a/src/pcm/pcm_dmix_x86_64.c b/src/pcm/pcm_dmix_x86_64.c index 4d882bfd..1c80e181 100644 --- a/src/pcm/pcm_dmix_x86_64.c +++ b/src/pcm/pcm_dmix_x86_64.c @@ -87,8 +87,7 @@ static void mix_select_callbacks(snd_pcm_direct_t *dmix) /* try to determine, if we have SMP */ in = fopen("/proc/cpuinfo", "r"); if (in) { - while (!feof(in)) { - fgets(line, sizeof(line), in); + while (!feof(in) && (fgets(line, sizeof(line), in) != NULL)) { if (!strncmp(line, "processor", 9)) smp++; }