Skip to content
Snippets Groups Projects
Commit f9eebda6 authored by Meredith L. Patterson's avatar Meredith L. Patterson
Browse files

fix segfault with optimized code; initialize TSRM stuff

parent b9ce12f3
No related branches found
No related tags found
No related merge requests found
...@@ -69,7 +69,7 @@ dbg = env.Clone(VARIANT='debug') ...@@ -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
......
%module hammer; %module hammer;
%include "exception.i"; %include "exception.i";
%{
#include "allocator.h"
%}
%ignore HCountedArray_; %ignore HCountedArray_;
...@@ -8,6 +11,7 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment