diff options
author | Tomohiro IKEDA <rilakkuma.san.xjapan@gmail.com> | 2022-06-15 08:45:19 +0900 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2022-06-17 10:23:43 +0200 |
commit | ff0db96bbc16440f6f0558f797bcc31e89f6df9e (patch) | |
tree | 09f342f986441f35116130ff18aa12cc05ebbe03 | |
parent | 2d56ff8ded18d387c094e0e3b83d68ae3a133101 (diff) | |
download | alsa-lib-ff0db96bbc16440f6f0558f797bcc31e89f6df9e.tar.gz |
pcm: dmix - Add error handler for `fgets`
Fixes: https://github.com/alsa-project/alsa-lib/pull/238
Signed-off-by: Tomohiro IKEDA <rilakkuma.san.xjapan@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r-- | src/pcm/pcm_dmix_i386.c | 3 | ||||
-rw-r--r-- | src/pcm/pcm_dmix_x86_64.c | 3 |
2 files changed, 2 insertions, 4 deletions
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++; } |