alsactl: fix error path code in init_parse.c

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>
This commit is contained in:
Jaroslav Kysela 2009-12-14 17:26:57 +01:00 committed by Jaroslav Kysela
parent 87ee474b1d
commit 1247c3d8ac

View 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();