cvs: ZendEngine2(PHP_5_3) / zend_compile.c /tests declare_001.phpt

"Felipe Pena" <[email protected]>
Newsgroups gmane.comp.php.cvs.zend
Message-ID <cvsfelipe1226420153@cvsserver>
felipe		Tue Nov 11 16:15:53 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /ZendEngine2/tests	declare_001.phpt 

  Modified files:              
    /ZendEngine2	zend_compile.c 
  Log:
  - Fixed bug #46546 (Segmentation fault when using declare statement with non-string value)
  # This issue only happens in this branch
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.41.2.87&r2=1.647.2.27.2.41.2.88&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.87 ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.88
--- ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.87	Tue Nov  4 15:58:50 2008
+++ ZendEngine2/zend_compile.c	Tue Nov 11 16:15:52 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.87 2008/11/04 15:58:50 helly Exp $ */
+/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.88 2008/11/11 16:15:52 felipe Exp $ */
 
 #include <zend_language_parser.h>
 #include "zend.h"
@@ -4770,12 +4770,13 @@
 				zend_multibyte_yyinput_again(old_input_filter, old_encoding TSRMLS_CC);
 			}
 		}
+		efree(val->u.constant.value.str.val);
 #else  /* !ZEND_MULTIBYTE */
 	} else if (!zend_binary_strcasecmp(var->u.constant.value.str.val, var->u.constant.value.str.len, "encoding", sizeof("encoding")-1)) {
 		/* Do not generate any kind of warning for encoding declares */
 		/* zend_error(E_COMPILE_WARNING, "Declare encoding [%s] not supported", val->u.constant.value.str.val); */
+		zval_dtor(&val->u.constant);
 #endif /* ZEND_MULTIBYTE */
-		efree(val->u.constant.value.str.val);
 	} else {
 		zend_error(E_COMPILE_WARNING, "Unsupported declare '%s'", var->u.constant.value.str.val);
 		zval_dtor(&val->u.constant);

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/declare_001.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/declare_001.phpt
+++ ZendEngine2/tests/declare_001.phpt
--TEST--
Testing declare statement with several type values
--FILE--
<?php

declare(encoding = 1);
declare(encoding = 1.2);
declare(encoding = NULL);
declare(encoding = M_PI);
declare(encoding = 'utf-8');

print 'DONE';

?>
--EXPECTF--
Warning: Unsupported encoding [1] in %s on line %d

Warning: Unsupported encoding [1.2] in %s on line %d

Warning: Unsupported encoding [] in %s on line %d

Fatal error: Cannot use constants as encoding in %s on line %d



-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.