Fix SVACE defect (DEREF_OF_NULL.RET.ALLOC) 11/255811/1 accepted/tizen_unified tizen accepted/tizen/unified/20210328.230654 submit/tizen/20210324.043440
authorSeungbae Shin <seungbae.shin@samsung.com>
Wed, 24 Mar 2021 03:58:37 +0000 (12:58 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Wed, 24 Mar 2021 03:58:37 +0000 (12:58 +0900)
[Version] 0.2.27
[Issue Type] Svace

Change-Id: I4753db62a0b565649bd4dd1f47aa30a4eaf63265

packaging/audio-hal-ak4953.spec
tizen-audio-impl-ucm.c

index be256b37146b453bb2dbbe8a30ec2070c03d7d73..05262139efe460e9aad3063da28a170b5ab4c92e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       audio-hal-ak4953
 Summary:    TIZEN Audio HAL for AK4953
-Version:    0.2.26
+Version:    0.2.27
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 1dfe50a70ab798106e6d340e369d6dcc82392bc3..5b062082fa8e6d3355bad00dd1275f7a0b1b568f 100644 (file)
@@ -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
+}