diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index bbdd95249..faf4fe070 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2249,11 +2249,13 @@ public: if (tm) tm = Copy(tm); } - if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { - Replaceall(tm, "$error", "EG(exception)"); - Printv(w->code, Str(tm), "\n", NIL); + if (!tm || Len(tm) == 0 || Equal(tm, "1")) { + // Skip marshalling the return value as there isn't one. + tm = NewString("if ($error) SWIG_fail;"); } - Append(w->code, "}\n"); + + Replaceall(tm, "$error", "EG(exception)"); + Printv(w->code, Str(tm), "\n}\n{\n", NIL); Delete(tm); /* marshal return value from PHP to C/C++ type */ @@ -2301,6 +2303,8 @@ public: } } + Append(w->code, "}\n"); + Delete(cleanup); Delete(outarg); }