summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-03-19 10:52:24 +0100
committerTakashi Iwai <tiwai@suse.de>2014-03-19 10:52:24 +0100
commitdbe6d7f86902dbbe2ff276b7a6524c084893772f (patch)
tree293f27a9a9e67c0f15e7cb6fd4cdc83d4f8a5194
parentd794af65e97822a29945a21c1cd2a21ea3b8e6b8 (diff)
downloadalsa-lib-dbe6d7f86902dbbe2ff276b7a6524c084893772f.tar.gz
route: Fix invalid pointer access
An uninitialized chmap pointer value is assigned in _snd_pcm_route_open(). Add NULL initializations appropriately, and also avoid the possible invalid access of NULL pcmp pointer. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--src/pcm/pcm_route.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c
index a9097caa..599fc3eb 100644
--- a/src/pcm/pcm_route.c
+++ b/src/pcm/pcm_route.c
@@ -1361,7 +1361,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
int err;
snd_pcm_t *spcm;
snd_config_t *slave = NULL, *sconf;
- snd_pcm_chmap_t *tt_chmap, *chmap;
+ snd_pcm_chmap_t *tt_chmap = NULL, *chmap = NULL;
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
int schannels = -1;
snd_config_t *tt = NULL;
@@ -1460,8 +1460,9 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
if (err < 0) {
free(chmap);
snd_pcm_close(spcm);
+ } else {
+ ((snd_pcm_route_t*) (*pcmp)->private_data)->chmap = chmap;
}
- ((snd_pcm_route_t*) (*pcmp)->private_data)->chmap = chmap;
return err;
}