Browse code

- 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 authored on 27/07/2007 14:21:04
Showing 1 changed files
... ...
@@ -810,19 +810,25 @@ inline static int comp_select(int op, select_t* sel, int rtype, union exp_op* r,
810 810
 {
811 811
 	int ret;
812 812
 	str val;
813
+	char empty_str=0;
813 814
 
814 815
 	ret = run_select(&val, sel, msg);
815 816
 	if (ret < 0) return -1;
816 817
 	if (ret > 0) return 0;
817
-	if (val.len==0) return 0;
818 818
 
819 819
 	switch(op) {
820
-	case NO_OP: return 1;
820
+	case NO_OP: return (val.len>0);
821 821
 	case BINOR_OP:
822 822
 	case BINAND_OP:
823 823
 		ERR("Binary operators cannot be used with string selects\n");
824 824
 		return -1;
825 825
 	}
826
+	if (val.len==0) {
827
+		/* make sure the string pointer uses accessible memory range
828
+		 * the comp_str function might dereference it
829
+		 */
830
+		val.s=&empty_str;
831
+	}
826 832
 	return comp_str(op, &val, rtype, r, msg);
827 833
 }
828 834