Prechádzať zdrojové kódy

[Core] Coverity: Dereference before null check

* [Core] Coverity: 1060958 Dereference before null check

* [Core] Coverity: 1024236 Dereference before null check
Andrey Volk 1 rok pred
rodič
commit
79ce088101
2 zmenil súbory, kde vykonal 4 pridanie a 2 odobranie
  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++;