]> git.alsa-project.org Git - alsa-lib.git/commitdiff
route: Fix invalid pointer access
authorTakashi Iwai <tiwai@suse.de>
Wed, 19 Mar 2014 09:52:24 +0000 (10:52 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 19 Mar 2014 09:52:24 +0000 (10:52 +0100)
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>
src/pcm/pcm_route.c

index a9097caa7303dd8eb1610778e260946762b45ea8..599fc3eb48e28d3c35699dcddbd226b2af763a50 100644 (file)
@@ -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;
 }