Browse Source

backported fixed for handling failed mallocs

Jiri Kuthan 21 years ago
parent
commit
ad781d248e
1 changed files with 1 additions and 1 deletions
  1. 1 1
      re.c

+ 1 - 1
re.c

@@ -481,11 +481,11 @@ str* subst_str(char *input, struct sip_msg* msg, struct subst_expr* se)
 		goto error;
 		goto error;
 	}
 	}
 	res->s=pkg_malloc(len+1); /* space for null termination */
 	res->s=pkg_malloc(len+1); /* space for null termination */
-	res->s[len]=0;
 	if (res->s==0){
 	if (res->s==0){
 		LOG(L_ERR, "ERROR: subst_str: mem. allocation error (res->s)\n");
 		LOG(L_ERR, "ERROR: subst_str: mem. allocation error (res->s)\n");
 		goto error;
 		goto error;
 	}
 	}
+	res->s[len]=0;
 	res->len=len;
 	res->len=len;
 	
 	
 	/* replace */
 	/* replace */