]> granicus.if.org Git - php/commitdiff
add error if __HALT_COMPILER(); is not declared and new test
authorGreg Beaver <cellog@php.net>
Thu, 8 Dec 2005 06:38:26 +0000 (06:38 +0000)
committerGreg Beaver <cellog@php.net>
Thu, 8 Dec 2005 06:38:26 +0000 (06:38 +0000)
ext/phar/phar.c
ext/phar/tests/002.phpt
ext/phar/tests/004.phpt [new file with mode: 0644]

index d69fcf4f2b9f84ea1583b0ccc861fd9cc9b9ce5a..c750d21798299a40970ca2830d3a55e15a752f3e 100644 (file)
@@ -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);
index eba105c323c8e54aa52366c4f90fe01947c37017..8220fae1bb9824785a6f88f5b5e2af964aec13b4 100644 (file)
@@ -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 (file)
index 0000000..02beb8a
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+PHP_Archive::mapPhar improper parameters
+--SKIPIF--
+<?php if (!extension_loaded("phar")) print "skip";?>
+--FILE--
+<?php
+PHP_Archive::mapPhar(5, 'hio', false);
+?>
+--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