]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsactl: Fix potential NULL dereferences in daemon mode
authorTakashi Iwai <tiwai@suse.de>
Fri, 9 Dec 2016 16:28:47 +0000 (17:28 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 9 Dec 2016 16:28:47 +0000 (17:28 +0100)
The code releasing the each card object may access to NULL when a
bogus count is given.  Add a NULL check just to make sure.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
alsactl/daemon.c

index 127701efaf0fdf59dc8adfd336018056e7d50906..4f0a935a3987bd603035d1482d7d173eeb17e0b7 100644 (file)
@@ -451,8 +451,10 @@ save:
 out:
        free(pfd);
        remove(pidfile);
-       for (i = 0; i < count; i++)
-               card_free(&cards[i]);
-       free(cards);
+       if (cards) {
+               for (i = 0; i < count; i++)
+                       card_free(&cards[i]);
+               free(cards);
+       }
        return 0;
 }