--- /dev/null
+--- SWIG/Source/Modules/php4.cxx.orig 2003-10-07 22:11:59.308330872 +0200
++++ SWIG/Source/Modules/php4.cxx 2003-10-07 22:11:33.000000000 +0200
+@@ -1149,6 +1149,8 @@
+
+ /* Insert cleanup code */
+ for (i = 0, p = l; p; i++) {
++ if(i>= (num_required))
++ Printf(cleanup,"\tif(arg_count > %d) {\n", i);
+ if ((tm = Getattr(p,"tmap:freearg"))) {
+ Replaceall(tm,"$source",Getattr(p,"lname"));
+ Printv(cleanup,tm,"\n",NIL);
+@@ -1156,6 +1158,8 @@
+ } else {
+ p = nextSibling(p);
+ }
++ if (i >= num_required)
++ Printf(cleanup,"}\n");
+ }
+
+ /* Insert argument output code */