diff options
author | Dong Jinguang <dongjinguang@huawei.com> | 2017-12-07 21:09:43 +0800 |
---|---|---|
committer | Dong Jinguang <dongjinguang@huawei.com> | 2017-12-08 09:25:17 +0800 |
commit | f58a7f6147d87158de8b7857907f54bb87b333eb (patch) | |
tree | 1f0a66bd566b25eaeb6da18082f6e7cc4e9f05d5 | |
parent | dd5e6e374ce2b5d46edc2fa0059f874595a883ff (diff) | |
download | tinyalsa-f58a7f6147d87158de8b7857907f54bb87b333eb.tar.gz |
tinyalsa: check NULL for config
pcm_open() was not checking config and crashed memory leak
Test: built and ran on device without errors
Change-Id: Icdd6271b0c5d6107b8bfc043f26a63b2829712b3
-rw-r--r-- | pcm.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -882,8 +882,11 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, char fn[256]; int rc; + if (!config) { + return &bad_pcm; /* TODO: could support default config here */ + } pcm = calloc(1, sizeof(struct pcm)); - if (!pcm || !config) + if (!pcm) return &bad_pcm; /* TODO: could support default config here */ pcm->config = *config; |