From 6ff5c1f97449aa22d92c7c7542c753d63a15b159 Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Thu, 8 Dec 2005 06:38:26 +0000 Subject: [PATCH] add error if __HALT_COMPILER(); is not declared and new test --- ext/phar/phar.c | 7 ++++++- ext/phar/tests/002.phpt | 1 + ext/phar/tests/004.phpt | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 ext/phar/tests/004.phpt diff --git a/ext/phar/phar.c b/ext/phar/phar.c index d69fcf4f2b..c750d21798 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -135,7 +135,12 @@ PHP_METHOD(PHP_Archive, mapPhar) } MAKE_STD_ZVAL(halt_constant); - zend_get_constant("__COMPILER_HALT_OFFSET__", 24, halt_constant TSRMLS_CC); + if (0 == zend_get_constant("__COMPILER_HALT_OFFSET__", 24, halt_constant TSRMLS_CC)) { + zval_dtor(halt_constant); + FREE_ZVAL(halt_constant); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "__HALT_COMPILER(); must be declared in a phar"); + return; + } halt_offset = Z_LVAL(*halt_constant); zval_dtor(halt_constant); FREE_ZVAL(halt_constant); diff --git a/ext/phar/tests/002.phpt b/ext/phar/tests/002.phpt index eba105c323..8220fae1bb 100644 --- a/ext/phar/tests/002.phpt +++ b/ext/phar/tests/002.phpt @@ -10,6 +10,7 @@ PHP_Archive::mapPhar(5, 5); PHP_Archive::mapPhar(5, 'hio'); PHP_Archive::mapPhar(5, 'hio', 'hi'); PHP_Archive::mapPhar(5, 'hio', true, 5, 5); +__HALT_COMPILER(); ?> --EXPECTF-- Warning: PHP_Archive::mapPhar() expects at least 3 parameters, 0 given in %s on line %d diff --git a/ext/phar/tests/004.phpt b/ext/phar/tests/004.phpt new file mode 100644 index 0000000000..02beb8a784 --- /dev/null +++ b/ext/phar/tests/004.phpt @@ -0,0 +1,10 @@ +--TEST-- +PHP_Archive::mapPhar improper parameters +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Fatal error: PHP_Archive::mapPhar(): __HALT_COMPILER(); must be declared in a phar in %s on line %d \ No newline at end of file -- 2.50.1