Repository: swig/swig (language: cpp)

Issue:
Variables of array type are not initialized by `Swig_cargs`
In the `javascript_lib_arrays` unit test, the `arg1` argument of `sum2` is of type `a(3).int`.

This variable is declared without being initialized:

```
int *arg1;
```

Which becomes a problem once the `freearg` typemaps are applied on the error path.

`Swig_cargs` does not initialize arrays:
https://github.com/swig/swig/blob/68ec78b37abbfe11d0274411320e1320750c7bff/Source/Swig/cwrap.c#L299




Discussion / hints:

Fix patch:
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index 2da9e478765..0c32d0b97be 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -296,7 +296,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
 	  Delete(defname);
 	  Delete(defvalue);
 	}
-      } else if (!pvalue && ((tycode == T_POINTER) || (tycode == T_STRING) || (tycode == T_WSTRING))) {
+      } else if (!pvalue && ((tycode == T_POINTER) || (tycode == T_STRING) || (tycode == T_WSTRING) || (tycode == T_ARRAY))) {
 	pvalue = (String *) "0";
       }
       if (!altty) {


Test patch: