]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsactl: fix error path code in init_parse.c
authorJaroslav Kysela <perex@t61.perex-int.cz>
Mon, 14 Dec 2009 16:26:57 +0000 (17:26 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 14 Dec 2009 16:26:57 +0000 (17:26 +0100)
If initialization file (-i option) does not exists, the free_space()
function was called with NULL pointer.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
alsactl/init_parse.c

index 8d9c7ae0be90c936047d15791095a924887f1d4f..51b515c1941ae131d94c81f4c0c99d11411fdf3a 100644 (file)
@@ -1747,10 +1747,12 @@ int init(const char *filename, const char *cardname)
                        }
                        first = 0;
                        err = init_space(&space, card);
-                       if (err == 0 &&
-                           (space->rootdir = new_root_dir(filename)) != NULL)
-                               err = parse(space, filename);
-                       free_space(space);
+                       if (err == 0) {
+                               space->rootdir = new_root_dir(filename);
+                               if (space->rootdir != NULL)
+                                       err = parse(space, filename);
+                               free_space(space);
+                       }
                        if (err < 0)
                                break;
                }
@@ -1762,10 +1764,12 @@ int init(const char *filename, const char *cardname)
                }
                memset(&space, 0, sizeof(space));
                err = init_space(&space, card);
-               if (err == 0 &&
-                   (space->rootdir = new_root_dir(filename)) != NULL)
-                       err = parse(space, filename);
-               free_space(space);
+               if (err == 0) {
+                       space->rootdir = new_root_dir(filename);
+                       if (space->rootdir  != NULL)
+                               err = parse(space, filename);
+                       free_space(space);
+               }
        }
   error:
        sysfs_cleanup();