---
 src/alsa_ctl.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/src/alsa_ctl.c
+++ b/src/alsa_ctl.c
@@ -31,7 +31,7 @@ int alsa_ctl (misc_t *misc, int action,
    {
       FILE *r, *p;
       int found;                        
-      char *str;
+      char *str, *c;
       size_t bytes;
 
       if (! (r = fopen ("/proc/asound/cards", "r")))
@@ -52,7 +52,9 @@ int alsa_ctl (misc_t *misc, int action,
          if (getline (&str, &bytes, r) == -1)
             break;
          while (isspace (*++str));
-         *strrchr (str, ' ') = 0;
+         c = strrchr (str, ' ');
+         if (c)
+            *c = 0;
          snprintf (sound_devices[current_sink].name, 80, "(alsa) %s", str);
          sprintf (misc->cmd, "LANGUAGE=C /usr/bin/amixer -D %s get Master playback",
                   sound_devices[current_sink].device);
