Bug #52676 [Opn->Fbk]: Eval will crash script when function inside returns a string to be eval'ed

From: Date: Tue, 24 Aug 2010 00:35:07 +0000
Subject: Bug #52676 [Opn->Fbk]: Eval will crash script when function inside returns a string to be eval'ed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-153730@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52676&edit=1

 ID:                 52676
 Updated by:         felipe@php.net
 Reported by:        wolff dot schetula at gmail dot com
 Summary:            Eval will crash script when function inside returns
                     a string to be eval'ed
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            *General Issues
 Operating System:   any
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

Are you using any Zend Extension? I cannot reproduce any crash on 5.2,
5.3, trunk.


Previous Comments:
------------------------------------------------------------------------
[2010-08-23 10:24:45] wolff dot schetula at gmail dot com

Description:
------------
The code below shows the problem. Any return statement inside the
function that is supposed to create the code to be evaluated will crash
PHP. Not even Apache will send a header anymore. A white page appears.

If the returned string is stored i a variable first it will work fine.
The quickest fix is a (string) cast inside the eval function.

eval((string)foo());

Test script:
---------------
function foo() {
    return 'echo time();';
}

eval(foo());



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52676&edit=1


Thread (4 messages)

« previous php.bugs (#153730) next »