]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: dmix - Add error handler for `fgets`
authorTomohiro IKEDA <rilakkuma.san.xjapan@gmail.com>
Tue, 14 Jun 2022 23:45:19 +0000 (08:45 +0900)
committerJaroslav Kysela <perex@perex.cz>
Fri, 17 Jun 2022 08:23:43 +0000 (10:23 +0200)
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>
src/pcm/pcm_dmix_i386.c
src/pcm/pcm_dmix_x86_64.c

index 82a91c5c2897ca3eebd4c66c10806f9328884d94..ea55d8ec0bdf07cf1f52852727316a9a15e6bc9c 100644 (file)
@@ -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)) {
index 4d882bfd01bfce336622d47d00e5a1d07469bf2f..1c80e1810f8425adedca221f9bac8f7a7ebb12c5 100644 (file)
@@ -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++;
                        }