diff options
author | Seungbae Shin <seungbae.shin@samsung.com> | 2021-03-10 11:28:48 +0900 |
---|---|---|
committer | Seungbae Shin <seungbae.shin@samsung.com> | 2021-03-10 11:28:48 +0900 |
commit | 6cc6364a3e7f987bb27c380ec5b83551c37f2686 (patch) | |
tree | dff1681b9fdf60d1d9d00cd04f2aa245c8f35688 | |
parent | 79af9a9d023abd3a6ad140b377380b029ec3772e (diff) | |
download | audio-hal-wm1831-accepted/tizen_unified.tar.gz audio-hal-wm1831-accepted/tizen_unified.tar.bz2 audio-hal-wm1831-accepted/tizen_unified.zip |
Fix SVACE defect (DEREF_OF_NULL.RET.ALLOC)submit/tizen/20210310.040512accepted/tizen/unified/20210310.144848tizenaccepted/tizen_unified
[Version] 0.1.14
[Issue Type] Svace
Change-Id: I7b35b84817149f114631ee5308104ee36320a284
-rw-r--r-- | packaging/audio-hal-wm1831.spec | 2 | ||||
-rw-r--r-- | tizen-audio-impl-ucm.c | 51 |
2 files changed, 19 insertions, 34 deletions
diff --git a/packaging/audio-hal-wm1831.spec b/packaging/audio-hal-wm1831.spec index f9cdb6c..d2da535 100644 --- a/packaging/audio-hal-wm1831.spec +++ b/packaging/audio-hal-wm1831.spec @@ -1,6 +1,6 @@ Name: audio-hal-wm1831 Summary: TIZEN Audio HAL for WM1831 -Version: 0.1.13 +Version: 0.1.14 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/tizen-audio-impl-ucm.c b/tizen-audio-impl-ucm.c index 2c42613..8d7e83a 100644 --- a/tizen-audio-impl-ucm.c +++ b/tizen-audio-impl-ucm.c @@ -24,6 +24,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <assert.h> #ifdef ALSA_UCM_DEBUG_TIME #include <sys/time.h> #include <time.h> @@ -170,28 +171,20 @@ audio_return_t _ucm_set_use_case(audio_hal_t *ah, const char *verb, const char * AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely"); if (old_dev_count > 0) { - dis_dev_list = (const char **)malloc(sizeof(const char *) * old_dev_count); - for (i = 0; i < old_dev_count; i++) { - dis_dev_list[i] = NULL; - } + dis_dev_list = (const char **)calloc(old_dev_count, sizeof(const char *)); + assert(dis_dev_list); } if (dev_count > 0) { - ena_dev_list = (const char **)malloc(sizeof(const char *) * dev_count); - for (i = 0; i < dev_count; i++) { - ena_dev_list[i] = NULL; - } + ena_dev_list = (const char **)calloc(dev_count, sizeof(const char *)); + assert(ena_dev_list); } if (old_mod_count > 0) { - dis_mod_list = (const char **)malloc(sizeof(const char *) * old_mod_count); - for (i = 0; i < old_mod_count; i++) { - dis_mod_list[i] = NULL; - } + dis_mod_list = (const char **)calloc(old_mod_count, sizeof(const char *)); + assert(dis_mod_list); } if (mod_count > 0) { - ena_mod_list = (const char **)malloc(sizeof(const char *) * mod_count); - for (i = 0; i < mod_count; i++) { - ena_mod_list[i] = NULL; - } + ena_mod_list = (const char **)calloc(mod_count, sizeof(const char *)); + assert(ena_mod_list); } /* update disable modifiers list which are not present in new modifier list */ @@ -378,16 +371,12 @@ audio_return_t _ucm_set_devices(audio_hal_t *ah, const char *verb, const char *d AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely"); if (old_dev_count > 0) { - dis_dev_list = (const char **)malloc(sizeof(const char *) * old_dev_count); - for (i = 0; i < old_dev_count; i++) { - dis_dev_list[i] = NULL; - } + dis_dev_list = (const char **)calloc(old_dev_count, sizeof(const char *)); + assert(dis_dev_list); } if (dev_count > 0) { - ena_dev_list = (const char **)malloc(sizeof(const char *) * dev_count); - for (i = 0; i < dev_count; i++) { - ena_dev_list[i] = NULL; - } + ena_dev_list = (const char **)calloc(dev_count, sizeof(const char *)); + assert(ena_dev_list); } /* update disable devices list which are not present in new device list */ @@ -513,16 +502,12 @@ audio_return_t _ucm_set_modifiers(audio_hal_t *ah, const char *verb, const char AUDIO_LOG_DEBUG("current verb and new verb is same. No need to change verb, disable devices explicitely"); if (old_mod_count > 0) { - dis_mod_list = (const char **)malloc(sizeof(const char *) * old_mod_count); - for (i = 0; i < old_mod_count; i++) { - dis_mod_list[i] = NULL; - } + dis_mod_list = (const char **)calloc(old_mod_count, sizeof(const char *)); + assert(dis_mod_list); } if (mod_count > 0) { - ena_mod_list = (const char **)malloc(sizeof(const char *) * mod_count); - for (i = 0; i < mod_count; i++) { - ena_mod_list[i] = NULL; - } + ena_mod_list = (const char **)calloc(mod_count, sizeof(const char *)); + assert(ena_mod_list); } /* update disable modifiers list which are not present in new modifier list */ @@ -648,4 +633,4 @@ audio_return_t _ucm_reset_use_case(audio_hal_t *ah) } return ret; -}
\ No newline at end of file +} |