[PHP] Fix cleanup code handling issues

Fix to call cleanup code in exception situations and not to invoke
the freearg typemap twice in certain situations.

Fixes https://sourceforge.net/p/swig/bugs/1211/
This commit is contained in:
Olly Betts 2022-02-17 13:02:05 +13:00
commit 1707d6b89b
9 changed files with 54 additions and 16 deletions

View file

@ -18,7 +18,6 @@ C_TEST_CASES += \
CPP_TEST_CASES += \
r_double_delete \
r_memory_leak \
r_overload_array \
r_sexp \
r_overload_comma \

View file

@ -1,8 +1,8 @@
clargs <- commandArgs(trailing=TRUE)
source(file.path(clargs[1], "unittest.R"))
dyn.load(paste("r_memory_leak", .Platform$dynlib.ext, sep=""))
source("r_memory_leak.R")
dyn.load(paste("exception_memory_leak", .Platform$dynlib.ext, sep=""))
source("exception_memory_leak.R")
cacheMetaData(1)
a <- Foo();
@ -13,6 +13,7 @@ unittest(Foo_get_count(), 2);
# Normal behaviour
invisible(trigger_internal_swig_exception("no problem", a));
unittest(Foo_get_count(), 2);
unittest(Foo_get_freearg_count(), 1);
# SWIG exception introduced
result <- tryCatch({
trigger_internal_swig_exception("null", b);
@ -24,3 +25,4 @@ result <- tryCatch({
unittest(1,1);
})
unittest(Foo_get_count(), 2);
unittest(Foo_get_freearg_count(), 2);