diff options
author | Seungbae Shin <seungbae.shin@samsung.com> | 2021-02-18 14:43:37 +0900 |
---|---|---|
committer | Seungbae Shin <seungbae.shin@samsung.com> | 2021-02-19 11:23:55 +0900 |
commit | ad6255edcc1e085b02f909dc96b9f7f7e82e4ded (patch) | |
tree | 3f98ad4c6142a4b770f90bb897a77bea55d02916 | |
parent | cf1d4f7947378e1f2b91141d377d647263df2a02 (diff) | |
download | audio-hal-exynos9110-ad6255edcc1e085b02f909dc96b9f7f7e82e4ded.tar.gz audio-hal-exynos9110-ad6255edcc1e085b02f909dc96b9f7f7e82e4ded.tar.bz2 audio-hal-exynos9110-ad6255edcc1e085b02f909dc96b9f7f7e82e4ded.zip |
Fix SVACE defect (DEREF_OF_NULL.RET.ALLOC)submit/tizen/20210219.045921accepted/tizen/unified/20210219.095226
[Version] 0.1.8
[Issue Type] Svace
Change-Id: I0de0b298178ec45a5dd7acc8cdfe41264efa93e1
-rw-r--r-- | packaging/audio-hal-exynos9110.spec | 2 | ||||
-rw-r--r-- | tizen-audio-impl-ucm.c | 49 |
2 files changed, 18 insertions, 33 deletions
diff --git a/packaging/audio-hal-exynos9110.spec b/packaging/audio-hal-exynos9110.spec index 413a585..9324c7e 100644 --- a/packaging/audio-hal-exynos9110.spec +++ b/packaging/audio-hal-exynos9110.spec @@ -1,6 +1,6 @@ Name: audio-hal-exynos9110 Summary: TIZEN Audio HAL for Exynos9110(TW3) -Version: 0.1.7 +Version: 0.1.8 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/tizen-audio-impl-ucm.c b/tizen-audio-impl-ucm.c index b20f56d..6b3fd0b 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_e _ucm_set_use_case(audio_hal_s *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 */ @@ -390,16 +383,12 @@ audio_return_e _ucm_set_devices(audio_hal_s *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 */ @@ -525,16 +514,12 @@ audio_return_e _ucm_set_modifiers(audio_hal_s *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 */ |