Browse Source

app_perl: move initialization of SIP message var after initialization of temporary environment

- upon a report by David Cunningham of a leak in operating system
  memory
Daniel-Constantin Mierla 12 years ago
parent
commit
6ff7470165
1 changed files with 5 additions and 6 deletions
  1. 5 6
      modules/app_perl/perlfunc.c

+ 5 - 6
modules/app_perl/perlfunc.c

@@ -127,16 +127,15 @@ int perl_exec2(struct sip_msg* _msg, char* fnc, char* mystr) {
 		return -1;
 	}
 
-	m = sv_newmortal();
-	sv_setref_pv(m, "Kamailio::Message", (void *)_msg);
-	SvREADONLY_on(SvRV(m));
-
-
 	ENTER;				/* everything created after here */
 	SAVETMPS;			/* ...is a temporary variable.   */
-	PUSHMARK(SP);			/* remember the stack pointer    */
+	PUSHMARK(SP);		/* remember the stack pointer    */
 	XPUSHs(m);			/* Our reference to the stack... */
 
+	m = sv_newmortal();
+	sv_setref_pv(m, "Kamailio::Message", (void *)_msg);
+	SvREADONLY_on(SvRV(m));
+
 	if (mystr)
 		XPUSHs(sv_2mortal(newSVpv(mystr, strlen(mystr))));
 					/* Our string to the stack... */