fix segfault with optimized code; initialize TSRM stuff
This commit is contained in:
parent
b9ce12f3b6
commit
f9eebda673
2 changed files with 11 additions and 3 deletions
|
|
@ -69,7 +69,7 @@ dbg = env.Clone(VARIANT='debug')
|
||||||
dbg.Append(CCFLAGS=['-g'])
|
dbg.Append(CCFLAGS=['-g'])
|
||||||
|
|
||||||
opt = env.Clone(VARIANT='opt')
|
opt = env.Clone(VARIANT='opt')
|
||||||
opt.Append(CCFLAGS="-O3")
|
opt.Append(CCFLAGS=["-O3"])
|
||||||
|
|
||||||
if GetOption("variant") == 'debug':
|
if GetOption("variant") == 'debug':
|
||||||
env = dbg
|
env = dbg
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
%module hammer;
|
%module hammer;
|
||||||
%include "exception.i";
|
%include "exception.i";
|
||||||
|
%{
|
||||||
|
#include "allocator.h"
|
||||||
|
%}
|
||||||
|
|
||||||
%ignore HCountedArray_;
|
%ignore HCountedArray_;
|
||||||
|
|
||||||
|
|
@ -8,6 +11,7 @@
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%init %{
|
%init %{
|
||||||
|
TSRMLS_FETCH();
|
||||||
h_tt_php = h_allocate_token_type("com.upstandinghackers.hammer.php");
|
h_tt_php = h_allocate_token_type("com.upstandinghackers.hammer.php");
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -161,9 +165,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
static HParsedToken* call_action(const HParseResult *p, void *user_data) {
|
static HParsedToken* call_action(const HParseResult *p, void *user_data) {
|
||||||
zval *args[1];
|
zval **args;
|
||||||
zval func;
|
zval func;
|
||||||
zval *ret;
|
zval *ret;
|
||||||
|
args = (zval**)h_arena_malloc(p->arena, sizeof(*args) * 1); // one-element array of pointers
|
||||||
|
MAKE_STD_ZVAL(args[0]);
|
||||||
ALLOC_INIT_ZVAL(ret);
|
ALLOC_INIT_ZVAL(ret);
|
||||||
ZVAL_STRING(&func, (const char*)user_data, 0);
|
ZVAL_STRING(&func, (const char*)user_data, 0);
|
||||||
hpt_to_php(p->ast, args[0]);
|
hpt_to_php(p->ast, args[0]);
|
||||||
|
|
@ -179,9 +185,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
static int call_predicate(HParseResult *p, void *user_data) {
|
static int call_predicate(HParseResult *p, void *user_data) {
|
||||||
zval *args[1];
|
zval **args;
|
||||||
zval func;
|
zval func;
|
||||||
zval *ret;
|
zval *ret;
|
||||||
|
args = (zval**)h_arena_malloc(p->arena, sizeof(*args) * 1); // one-element array of pointers
|
||||||
|
MAKE_STD_ZVAL(args[0]);
|
||||||
ALLOC_INIT_ZVAL(ret);
|
ALLOC_INIT_ZVAL(ret);
|
||||||
ZVAL_STRING(&func, (const char*)user_data, 0);
|
ZVAL_STRING(&func, (const char*)user_data, 0);
|
||||||
hpt_to_php(p->ast, args[0]);
|
hpt_to_php(p->ast, args[0]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue