6 Commits

Author SHA1 Message Date
Xinchen Hui
e350b425f4 release 2.0.4 2017-07-12 11:42:06 +08:00
Xinchen Hui
527f927ead Fixed bug #73964 (Segmentation fault (11)) 2017-02-12 10:53:36 +08:00
Xinchen Hui
9be57325c6 back to dev 2017-02-10 19:14:10 +08:00
Xinchen Hui
1ff1eb10c9 releaseing 2.0.3 2017-02-10 19:13:44 +08:00
Xinchen Hui
cbe65b9ad6 Fixed issue #20 (PHP 7: Lua::eval(): unsupported type `unknown' for lua) 2016-05-30 11:44:12 +08:00
Xinchen Hui
04f7106631 back to dev 2016-05-26 17:42:59 +08:00
4 changed files with 101 additions and 9 deletions

19
lua.c
View File

@@ -174,6 +174,11 @@ static void php_lua_dtor_object(zend_object *object) /* {{{ */ {
php_lua_object *lua_obj = php_lua_obj_from_obj(object);
zend_object_std_dtor(&(lua_obj->obj));
}
/* }}} */
static void php_lua_free_object(zend_object *object) /* {{{ */ {
php_lua_object *lua_obj = php_lua_obj_from_obj(object);
if (lua_obj->L) {
lua_close(lua_obj->L);
@@ -351,7 +356,7 @@ zval *php_lua_get_zval_from_lua(lua_State *L, int index, zval *lua_obj, zval *rv
break;
}
switch(Z_TYPE(key)) {
switch (Z_TYPE(key)) {
case IS_DOUBLE:
case IS_LONG:
add_index_zval(rv, Z_DVAL(key), &val);
@@ -401,6 +406,7 @@ zval *php_lua_get_zval_from_lua(lua_State *L, int index, zval *lua_obj, zval *rv
int php_lua_send_zval_to_lua(lua_State *L, zval *val) /* {{{ */ {
try_again:
switch (Z_TYPE_P(val)) {
case IS_TRUE:
lua_pushboolean(L, 1);
@@ -408,6 +414,7 @@ int php_lua_send_zval_to_lua(lua_State *L, zval *val) /* {{{ */ {
case IS_FALSE:
lua_pushboolean(L, 0);
break;
case IS_UNDEF:
case IS_NULL:
lua_pushnil(L);
break;
@@ -472,6 +479,14 @@ int php_lua_send_zval_to_lua(lua_State *L, zval *val) /* {{{ */ {
}
}
break;
case IS_REFERENCE:
ZVAL_DEREF(val);
goto try_again;
break;
case IS_INDIRECT:
val = Z_INDIRECT_P(val);
goto try_again;
break;
default:
php_error_docref(NULL, E_ERROR, "unsupported type `%s' for lua", zend_zval_type_name(val));
lua_pushnil(L);
@@ -821,7 +836,7 @@ PHP_MINIT_FUNCTION(lua) {
memcpy(&lua_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
lua_object_handlers.offset = XtOffsetOf(php_lua_object, obj);
lua_object_handlers.dtor_obj = php_lua_dtor_object;
lua_object_handlers.free_obj = NULL;
lua_object_handlers.free_obj = php_lua_free_object;
lua_object_handlers.clone_obj = NULL;
lua_object_handlers.write_property = php_lua_write_property;
lua_object_handlers.read_property = php_lua_read_property;

View File

@@ -23,11 +23,11 @@
<email>msaraujo@php.net</email>
<active>yes</active>
</developer>
<date>2016-05-26</date>
<time>10:50:27</time>
<date>2017-07-12</date>
<time>19:15:00</time>
<version>
<release>2.0.2</release>
<api>2.0.2</api>
<release>2.0.4</release>
<api>2.0.4</api>
</version>
<stability>
<release>stable</release>
@@ -35,7 +35,7 @@
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>
- Fixed issue #22 (Boolean FALSE is always TRUE)
- Fixed bug #73964 (Segmentation fault)
</notes>
<contents>
<dir name="/">
@@ -65,6 +65,7 @@
<file name="issue012.phpt" role="test" />
<file name="bug65097.phpt" role="test" />
<file name="bug71997.phpt" role="test" />
<file name="bug73964.phpt" role="test" />
</dir>
</dir>
</contents>
@@ -81,6 +82,38 @@
<providesextension>lua</providesextension>
<extsrcrelease />
<changelog>
<release>
<date>2017-02-10</date>
<version>
<release>2.0.3</release>
<api>2.0.3</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
- Fixed issue #20 (PHP 7: Lua::eval(): unsupported type `unknown' for lua)
</notes>
</release>
<release>
<date>2017-07-12</date>
<version>
<release>2.0.4</release>
<api>2.0.4</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
- Fixed bug #73964 (Segmentation fault)
</notes>
</release>
<release>
<date>2016-05-26</date>
<version>
@@ -96,7 +129,6 @@
- Fixed issue #22 (Boolean FALSE is always TRUE)
</notes>
</release>
<release>
<date>2016-04-11</date>
<version>

View File

@@ -48,7 +48,7 @@ extern zend_module_entry lua_module_entry;
#define LUA_G(v) (lua_globals.v)
#endif
#define PHP_LUA_VERSION "2.0.2"
#define PHP_LUA_VERSION "2.0.4"
struct _php_lua_object {
lua_State *L;

45
tests/bug73964.phpt Normal file
View File

@@ -0,0 +1,45 @@
--TEST--
Bug #73964 (Segmentation fault (11))
--SKIPIF--
<?php
if (!extension_loaded("lua")) print "skip lua extension missing";
?>
--FILE--
<?php
class LuaTest
{
function __construct()
{
$this->lua = new Lua();
$this->lua->registerCallback("log", array($this, "API_LuaLog"));
}
function API_LuaLog( $entry)
{
echo("from lua: $entry");
}
public function RunTest()
{
$this->lua->eval(<<<CODE
function TestFunc(str)
log(str)
end
CODE
);
$GamePackage = $this->lua->RootTable;
$this->lua->call("TestFunc", array("okey"));
}
}
$a = new LuaTest();
$a->runtest();
?>
--EXPECT--
from lua: okey