RE: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_operators.c
| From: | Dmitry Stogov | Date: | Sun, 09 Oct 2005 09:39:20 +0000 |
| Subject: | RE: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_operators.c | ||
| References: | 1 | Groups: | php.zend-engine.cvs |
| Request: | Send a blank email to php-zend-engine-cvs+get-4219@lists.php.net to get a copy of this message | ||
Hi Marcus,
At first you did allocate new zval* but didn't free it.
Also you didn't care about previous values of refcount/is_ref.
I don't ubdestand which macro you suggest to use, but may be I forgot
something.
Thanks. Dmitry.
> -----Original Message-----
> From: Marcus Boerger [mailto:helly@php.net]
> Sent: Friday, October 07, 2005 10:25 PM
> To: Dmitry Stogov
> Cc: zend-engine-cvs@lists.php.net
> Subject: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_operators.c
>
>
> Hello Dmitry,
>
> Friday, October 7, 2005, 12:06:48 PM, you wrote:
>
> > dmitry Fri Oct 7 06:06:48 2005 EDT
>
> > Modified files:
> > /ZendEngine2 zend_operators.c
> > Log:
> > Fixed memory leak
> >
> >
> >
>
> http://cvs.php.net/diff.php/ZendEngine2/zend_operators.c?r1=1.222&r2=1
> > .223&ty=u
> > Index: ZendEngine2/zend_operators.c
> > diff -u ZendEngine2/zend_operators.c:1.222
> ZendEngine2/zend_operators.c:1.223
> > --- ZendEngine2/zend_operators.c:1.222 Wed Oct 5 15:02:27 2005
> > +++ ZendEngine2/zend_operators.c Fri Oct 7 06:06:45 2005
> > @@ -17,7 +17,7 @@
> >
> >
> +-------------------------------------------------------------
> ---------+
> > */
> >
> > -/* $Id: zend_operators.c,v 1.222 2005/10/05 19:02:27 helly Exp $ */
> > +/* $Id: zend_operators.c,v 1.223 2005/10/07 10:06:45
> dmitry Exp $ */
> >
> > #include <ctype.h>
> >
> > @@ -319,15 +319,15 @@
> >
> > #define convert_object_to_type(op, ctype, conv_func)
>
> > if (Z_OBJ_HT_P(op)->cast_object) {
>
> > - zval *org;
>
> > - ALLOC_ZVAL(org);
>
> > - *org = *op;
>
> > - if (Z_OBJ_HT_P(op)->cast_object(org, op,
> ctype TSRMLS_CC)
> > == FAILURE) { \
> > + zval dst;
>
> > + if (Z_OBJ_HT_P(op)->cast_object(op, &dst, ctype
> > TSRMLS_CC) == FAILURE) { \
> > zend_error(E_RECOVERABLE_ERROR,
>
> > - "Object of class %v could not be
> converted to " # ctype, Z_OBJCE_P(org)->name); \
> > - INIT_ZVAL(*op);
>
> > + "Object of class %v could not be
> converted to " # ctype, Z_OBJCE_P(op)->name); \
> > + } else {
>
> > + zval_dtor(op);
>
> > + op->type = ctype;
>
> > + op->value = dst.value;
>
> I don't understand the big difference, but anyway why didn't
> you use a ZVAL assign/copy macro here? Are you sure the cast
> cannot require that?
>
> > }
>
> > - zval_dtor(org);
>
> > } else {
>
> > if(Z_OBJ_HT_P(op)->get) {
>
> > zval *newop = Z_OBJ_HT_P(op)->get(op
> > TSRMLS_CC);
>
>
>
>
> Best regards,
> Marcus
>
>