ttuegel / alsa-mixer

Haskell bindings to the ALSA mixer API
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

Avoid returning [NULL] if mixer elements are empty #13

Closed mbwgh closed 9 months ago

mbwgh commented 9 months ago

This PR adds a check to avoid dereferencing NULL inside simpleElement.

If the given mixer's element list is empty, both snd_mixer_first_elem and snd_mixer_last_elem will return NULL, which means elements' will return nullPtr : [] == [nullPtr].

This is triggered e.g. here, when xmobar will crash immediately after system start or resume from suspend, when mixer elements are not available yet for a short time.