Fix Coverity Defects 21/156621/2 tizen_4.0_tv accepted/tizen/4.0/unified/20171019.235337 submit/tizen_4.0/20171019.073238 tizen_4.0.IoT.p2_release tizen_4.0.m2_release
authorSeungbae Shin <seungbae.shin@samsung.com>
Thu, 19 Oct 2017 07:19:49 +0000 (16:19 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Thu, 19 Oct 2017 07:27:25 +0000 (16:27 +0900)
[Version] 5.0.175
[Issue Type] Security

Change-Id: I90606af4387eb473c9edc8fa3b892d0bfde85074

packaging/pulseaudio-modules-tizen.spec
src/module-tizenaudio-sink.c
src/stream-manager.c

index 869cc940f291c36a5ba2b828325741904be2c7c6..0dab3be89ab459a3d765f77a90bf32426aae1e66 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          5.0.174
+Version:          5.0.175
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index d81cecc5c69e53b1e4b03049bd46c61bdb6e110c..95b349a225af0e32238a8eb98c6a86f4bdba9b87 100644 (file)
@@ -163,16 +163,25 @@ static int suspend(struct userdata *u) {
 static int unsuspend(struct userdata *u) {
     pa_sample_spec sample_spec;
     int32_t ret;
+    size_t frame_size;
+
     pa_assert(u);
     pa_assert(!u->pcm_handle);
 
     pa_log_info("Trying resume...");
+
     sample_spec = u->sink->sample_spec;
+    frame_size = pa_frame_size(&sample_spec);
+    if (frame_size == 0) {
+        pa_log_error("Unexpected frame size zero!");
+        goto fail;
+    }
+
     ret = pa_hal_interface_pcm_open(u->hal_interface,
               (void **)&u->pcm_handle,
               DIRECTION_OUT,
               &sample_spec,
-              u->frag_size / pa_frame_size(&sample_spec),
+              u->frag_size / frame_size,
               u->nfrags);
     if (ret) {
         pa_log_error("Error opening PCM device %x", ret);
@@ -322,6 +331,10 @@ static int process_render(struct userdata *u, pa_usec_t now) {
     while (u->timestamp < now + u->block_usec) {
         pa_memchunk chunk;
         frame_size = pa_frame_size(&u->sink->sample_spec);
+        if (frame_size == 0) {
+            pa_log_error("Unexpected frame size zero!");
+            break;
+        }
 
         pa_hal_interface_pcm_available(u->hal_interface, u->pcm_handle, &avail);
         if ((avail == 0) && !(u->first)) {
index aed4bad9f25e753bab6f7797746ca334238ad755..c6a7d2645071fc163975490e17f079781ffa4491 100644 (file)
@@ -613,9 +613,9 @@ static void stream_info_free(stream_info *s) {
 }
 
 static int init_stream_map(pa_stream_manager *m) {
-    volume_info *v;
-    stream_info *s;
-    latency_info *l;
+    volume_info *v = NULL;
+    stream_info *s = NULL;
+    latency_info *l = NULL;
     json_object *o;
     json_object *array_o;
     json_object *array_item_o;
@@ -689,6 +689,7 @@ static int init_stream_map(pa_stream_manager *m) {
                     goto fail;
                 }
                 pa_hashmap_put(m->latency_infos, (void*)type, l);
+                l = NULL;
             }
         }
     }
@@ -716,6 +717,7 @@ static int init_stream_map(pa_stream_manager *m) {
                     goto fail;
                 }
                 pa_hashmap_put(m->volume_infos, (void*)type, v);
+                v = NULL;
             }
         }
     }
@@ -817,6 +819,7 @@ static int init_stream_map(pa_stream_manager *m) {
                     goto fail;
                 }
                 pa_hashmap_put(m->stream_infos, (void*)role, s);
+                s = NULL;
             }
         }
     } else {
@@ -830,6 +833,10 @@ static int init_stream_map(pa_stream_manager *m) {
 fail:
     pa_log_error("failed to initialize stream-map");
 
+    pa_xfree(v);
+    pa_xfree(s);
+    pa_xfree(l);
+
     if (m->stream_infos)
         pa_hashmap_free(m->stream_infos);
     if (m->volume_infos)