diff options
author | Seungbae Shin <seungbae.shin@samsung.com> | 2021-03-12 11:28:01 +0900 |
---|---|---|
committer | Seungbae Shin <seungbae.shin@samsung.com> | 2021-03-12 11:28:01 +0900 |
commit | bcd504d68566b5af09e7c855167f5790473af17d (patch) | |
tree | d495e74a81bcd888181ced73db566d84b4321d8b | |
parent | 98b9d058fdcdf0767b96c54e682428f37deb725f (diff) | |
download | audio-hal-max98090-bcd504d68566b5af09e7c855167f5790473af17d.tar.gz audio-hal-max98090-bcd504d68566b5af09e7c855167f5790473af17d.tar.bz2 audio-hal-max98090-bcd504d68566b5af09e7c855167f5790473af17d.zip |
Fix SVACE defect (DEREF_OF_NULL.RET.ALLOC)submit/tizen/20210314.161127submit/tizen/20210312.042839accepted/tizen/unified/20210315.134205tizenaccepted/tizen_unified
[Version] 0.2.28
[Issue Type] Svace
Change-Id: I8b6e6149b5c40b4d9b36cb11c7af2b8410a6f758
-rw-r--r-- | packaging/audio-hal-max98090.spec | 2 | ||||
-rw-r--r-- | tizen-audio-impl-ucm.c | 45 |
2 files changed, 17 insertions, 30 deletions
diff --git a/packaging/audio-hal-max98090.spec b/packaging/audio-hal-max98090.spec index 741d71c..8a7a131 100644 --- a/packaging/audio-hal-max98090.spec +++ b/packaging/audio-hal-max98090.spec @@ -1,6 +1,6 @@ Name: audio-hal-max98090 Summary: TIZEN Audio HAL for MAX98090 -Version: 0.2.27 +Version: 0.2.28 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/tizen-audio-impl-ucm.c b/tizen-audio-impl-ucm.c index 1dfe50a..ee3a76a 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,22 +171,16 @@ 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); @@ -378,16 +373,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 +504,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 +635,4 @@ audio_return_t _ucm_reset_use_case(audio_hal_t *ah) } return ret; -}
\ No newline at end of file +} |