Browse code

rvalues: fix rval_new( empty string )

- rval_new(RV_STR, empty string, ...) did not set properly the
string pointer

Andrei Pelinescu-Onciul authored on 19/02/2009 20:51:43
Showing 1 changed files
... ...
@@ -233,13 +233,17 @@ struct rvalue* rval_new(enum rval_type t, union rval_val* v, int extra_size)
233 233
 {
234 234
 	struct rvalue* rv;
235 235
 	
236
-	if (t==RV_STR && v && v->s.len)
236
+	if (t==RV_STR && v && v->s.s)
237 237
 		return rval_new_str(&v->s, extra_size);
238 238
 	rv=rval_new_empty(extra_size);
239 239
 	if (likely(rv)){
240 240
 		rv->type=t;
241
-		if (likely(v)){
241
+		if (likely(v && t!=RV_STR)){
242 242
 			rv->v=*v;
243
+		}else if (t==RV_STR){
244
+			rv->v.s.s=&rv->buf[0];
245
+			rv->v.s.len=0;
246
+			if (likely(extra_size)) rv->v.s.s[0]=0;
243 247
 		}else
244 248
 			memset (&rv->v, 0, sizeof(rv->v));
245 249
 	}