]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11903: Fix errors reported by PVS-Studio Static Code Analyzer for switch_profile.c
authorAndrey Volk <andywolk@gmail.com>
Fri, 12 Jul 2019 16:44:49 +0000 (20:44 +0400)
committerAndrey Volk <andywolk@gmail.com>
Mon, 15 Jul 2019 19:43:55 +0000 (23:43 +0400)
src/switch_profile.c

index 863c304913b18b34d22ea6e72c204011cce16c67..c9bd073a4c7dd052eeeb3ead3984abd07794ec38 100644 (file)
@@ -306,13 +306,16 @@ SWITCH_DECLARE(switch_profile_timer_t *)switch_new_profile_timer(void)
   unsigned int x;
   switch_profile_timer_t *p = calloc(1, sizeof(switch_profile_timer_t));
 
-  if ( runtime.cpu_idle_smoothing_depth && runtime.cpu_idle_smoothing_depth > 0 ) {
+  if (!p) return NULL;
+
+  if (runtime.cpu_idle_smoothing_depth > 0) {
          p->cpu_idle_smoothing_depth = runtime.cpu_idle_smoothing_depth;
   } else {
          p->cpu_idle_smoothing_depth = 30;
   }
 
   p->percentage_of_idle_time_ring = calloc(1, sizeof(double) * p->cpu_idle_smoothing_depth);
+  switch_assert(p->percentage_of_idle_time_ring);
 
   for ( x = 0; x < p->cpu_idle_smoothing_depth; x++ ) {
          p->percentage_of_idle_time_ring[x] = 100.0;