Re: RETURN_RT_STRING() and family leakage

From: Date: Mon, 03 Apr 2006 18:14:42 +0000
Subject: Re: RETURN_RT_STRING() and family leakage
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-22657@lists.php.net to get a copy of this message
duplicate should only ever be set to 0 on this (or any of the macros) when the string *is* allocated with emalloc. Otherwise the enegine would get in trouble freeing it later on.
No. :( You can use ZVAL_RT_STRING(&fname, "strlen", 0), then call zend_call_function(&fname) and do not destroy fname. Doi, of course, good point...
Okay, then the options are: (1) Assume auto_free for RETURN_RT_STRING(s,0) specifically as in this case, my statement above is valid since the engine IS going to try it eventually. Leave all other macros alone and make the calling scope handle the original string with the existing if (UG(unicode)) efree(s); Not my favorite. (2) Expand (ZVAL|RETVAL)_RT_STRING(s, 0) to include auto_free argument. This coule be done in conjunction with (1) or in place of it. (3) Overload duplicate argument to include (should I auto-free?) logic. (4) Duplicate the macros to one auto-free, and one non-auto-free version. I like the #1/#2 combo personally. -Sara

« previous php.internals (#22657) next »