[PHP] Fix access to already released memory
Fix access to already released memory during PHP module shutdown, which often didn't cause visible problems, but could result in segmentation faults, bus errors, etc. Fixes #1170, reported by Jitka Plesníková.
This commit is contained in:
parent
6833bb7e0f
commit
ab754b0c65
3 changed files with 11 additions and 5 deletions
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
%init %{
|
||||
SWIG_php_minit {
|
||||
SWIG_InitializeModule(0);
|
||||
SWIG_InitializeModule((void*)&module_number);
|
||||
%}
|
||||
|
||||
%fragment("swig_php_init_member_ptr2", "header") %{
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ static int default_error_code = E_ERROR;
|
|||
|
||||
/* Standard SWIG API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Php_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer, *(int*)clientdata)
|
||||
|
||||
/* used to wrap returned objects in so we know whether they are newobject
|
||||
and need freeing, or not */
|
||||
|
|
@ -230,7 +230,7 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
static char const_name[] = "swig_runtime_data_type_pointer";
|
||||
static const char const_name[] = "swig_runtime_data_type_pointer";
|
||||
static swig_module_info *SWIG_Php_GetModule() {
|
||||
zval *pointer = zend_get_constant_str(const_name, sizeof(const_name) - 1);
|
||||
if (pointer) {
|
||||
|
|
@ -241,6 +241,6 @@ static swig_module_info *SWIG_Php_GetModule() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void SWIG_Php_SetModule(swig_module_info *pointer) {
|
||||
REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, CONST_PERSISTENT | CONST_CS);
|
||||
static void SWIG_Php_SetModule(swig_module_info *pointer, int module_number) {
|
||||
REGISTER_LONG_CONSTANT(const_name, (long) pointer, CONST_CS | CONST_PERSISTENT);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue