Re[2]: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_execute.c

From: Date: Mon, 21 Jul 2003 07:48:22 +0000
Subject: Re[2]: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_execute.c
References: 1 2  Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1510@lists.php.net to get a copy of this message
At 09:56 21/07/2003, Marcus Börger wrote:
Hello Andi, Monday, July 21, 2003, 7:32:25 AM, you wrote: AG> This patch doesn't seem right. You shouldn't be checking the resulting AG> string str.val and str.len. If the value is converted to a string it should AG> always have a value and worst case you do a hash lookup with "" and then AG> error out because it's not found. AG> Please revert this patch and let's discuss a different way of fixing this. Andi that is the whole fix. Yes i know the string value is supposed to have a value but with uninitialized php variables the value itself isn't initialized.
The bug, in this case, was that the code assumed that the variable is an IS_STRING when in fact, it could have a different type. The fix, which involved looking at the string properties of the union was therefore wrong (although it worked under certain circumstances), because just like the original faulty code - it was assuming this zval was an IS_STRING. A couple of rules about IS_STRING zvals: - It will *always* have a valid str.val (and str.len, although that's less interesting). - Therefore, if you know for a fact that your zval has the type of IS_STRING, there is no need to check str.val for validity - If you find yourself having to check the validity of str.val, search elsewhere - chances are you just think that you're dealing with an IS_STRING, but in fact, you aren't.
So i suggest you either try to find why that can be possible or live with this patch. Perhaps we can reduce it and only set and check the length value.
We *cannot* live with patches of this sort even if they happen to fix a certain symptom - because they essentially only cover the real bug, and make it more difficult to find... That's what Andi meant when he said you weren't supposed to check validity of an IS_STRING through validating str.val and str.len - no matter what you may be doing. Zeev

« previous php.zend-engine.cvs (#1510) next »