Browse code

core: link regex before replacement field allocation can fail

- regex will be freed properly if there was an error for replacement

Daniel-Constantin Mierla authored on 21/04/2014 15:56:01
Showing 1 changed files
... ...
@@ -310,6 +310,7 @@ found_re:
310 310
 		goto error;
311 311
 	}
312 312
 	memset((void*)se, 0, sizeof(struct subst_expr));
313
+	se->re=regex;
313 314
 	se->replacement.len=repl_end-repl;
314 315
 	if (se->replacement.len > 0) {
315 316
 		if ((se->replacement.s=pkg_malloc(se->replacement.len))==0){
... ...
@@ -321,7 +322,6 @@ found_re:
321 322
 	} else {
322 323
 		se->replacement.s = NULL;
323 324
 	}
324
-	se->re=regex;
325 325
 	se->replace_all=replace_all;
326 326
 	se->n_escapes=rw_no;
327 327
 	se->max_pmatch=max_pmatch;