Parcourir la source

[Core] Coverity: Dereference before null check

* [Core] Coverity: 1060958 Dereference before null check

* [Core] Coverity: 1024236 Dereference before null check
Andrey Volk il y a 1 an
Parent
commit
79ce088101
2 fichiers modifiés avec 4 ajouts et 2 suppressions
  1. 3 1
      src/switch_ivr.c
  2. 1 1
      src/switch_ivr_originate.c

+ 3 - 1
src/switch_ivr.c

@@ -2814,11 +2814,13 @@ SWITCH_DECLARE(int) switch_ivr_set_xml_call_stats(switch_xml_t xml, switch_core_
 static int switch_ivr_set_xml_chan_var(switch_xml_t xml, const char *var, const char *val, int off)
 {
 	char *data;
-	switch_size_t dlen = strlen(val) * 3 + 1;
+	switch_size_t dlen;
 	switch_xml_t variable;
 
 	if (!val) val = "";
 
+	dlen = strlen(val) * 3 + 1;
+
 	if (!zstr(var) && ((variable = switch_xml_add_child_d(xml, var, off++)))) {
 		if ((data = malloc(dlen))) {
 			memset(data, 0, dlen);

+ 1 - 1
src/switch_ivr_originate.c

@@ -1309,7 +1309,7 @@ static switch_status_t setup_ringback(originate_global_t *oglobals, originate_st
 		}
 	}
 
-	if (oglobals->session && (read_codec = switch_core_session_get_read_codec(oglobals->session))) {
+	if ((read_codec = switch_core_session_get_read_codec(oglobals->session))) {
 		if (ringback_data && switch_is_file_path(ringback_data)) {
 			if (!(strrchr(ringback_data, '.') || strstr(ringback_data, SWITCH_URL_SEPARATOR))) {
 				ringback->asis++;