Преглед изворни кода

- revert partly fix which broke test of @select in route script.
- leave the correction for seg. fault on @select match against regexp.

- the comp_select and the select's itself need to be reviewed (I don't expect it will be done in 2.0)
= the select was created so it returns 1 if empty string, now it would be nice to return 1 for N/A values
and 0 (res.len=0) for empty strings
= now we need to ditinguish of N/A, empty and some value (e.g. for SIP request's header parameters)
= affects how the test is used in ser.cfg, so the example script will have to be reviewed too
(if (@to.tag=="") can't be true, as the tag MUST have value if present)

Michal Matyska пре 18 година
родитељ
комит
0be2fc378f
1 измењених фајлова са 8 додато и 2 уклоњено
  1. 8 2
      route.c

+ 8 - 2
route.c

@@ -810,19 +810,25 @@ inline static int comp_select(int op, select_t* sel, int rtype, union exp_op* r,
 {
 	int ret;
 	str val;
+	char empty_str=0;
 
 	ret = run_select(&val, sel, msg);
 	if (ret < 0) return -1;
 	if (ret > 0) return 0;
-	if (val.len==0) return 0;
 
 	switch(op) {
-	case NO_OP: return 1;
+	case NO_OP: return (val.len>0);
 	case BINOR_OP:
 	case BINAND_OP:
 		ERR("Binary operators cannot be used with string selects\n");
 		return -1;
 	}
+	if (val.len==0) {
+		/* make sure the string pointer uses accessible memory range
+		 * the comp_str function might dereference it
+		 */
+		val.s=&empty_str;
+	}
 	return comp_str(op, &val, rtype, r, msg);
 }