Program: 73359
Project: 73359
Buggy source:
private long _createMxArray(String name,Token t) throws IllegalActionException {
  long ma=0;
  if (t instanceof ArrayToken) {
    Token[] ta=((ArrayToken)t).arrayValue();
    if (!(ta[0] instanceof StringToken)) {
      ma=ptmatlabCreateCellMatrix(name,1,ta.length);
      if (ma == 0) {
        throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + name);
      }
      for (int n=0; n < ta.length; n++) {
        long fma=_createMxArray("String_Node_Str" + n + "String_Node_Str",ta[n]);
        if (fma == 0) {
          throw new IllegalActionException("String_Node_Str" + n + "String_Node_Str"+ name);
        }
        ptmatlabSetCell(name,ma,0,n,fma);
      }
    }
 else {
      String s=((StringToken)ta[0]).stringValue();
      ma=ptmatlabCreateString(name,s,ta.length,s.length());
      for (int n=1; n < ta.length; n++) {
        s=((StringToken)ta[n]).stringValue();
        ptmatlabSetString(name,ma,n,s,s.length());
      }
    }
  }
 else   if (t instanceof RecordToken) {
    Object[] fieldNames=(((RecordToken)t).labelSet()).toArray();
    ma=ptmatlabCreateStructMatrix(name,fieldNames,1,1);
    if (ma == 0) {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + name);
    }
    for (int n=0; n < fieldNames.length; n++) {
      Token f=((RecordToken)t).get((String)fieldNames[n]);
      long fma=_createMxArray((String)fieldNames[n],f);
      if (fma == 0) {
        throw new IllegalActionException("String_Node_Str" + fieldNames[n] + "String_Node_Str"+ name);
      }
      ptmatlabSetStructField(name,ma,(String)fieldNames[n],0,0,fma);
    }
  }
 else   if (t instanceof StringToken) {
    String s=((StringToken)t).stringValue();
    ma=ptmatlabCreateString(name,s,1,s.length());
  }
 else   if (t instanceof ComplexMatrixToken) {
    Complex[][] a=((ComplexMatrixToken)t).complexMatrix();
    ma=ptmatlabCreateComplexMatrix(name,a,a.length,a[0].length);
  }
 else   if (t instanceof MatrixToken) {
    double[][] a=((MatrixToken)t).doubleMatrix();
    ma=ptmatlabCreateDoubleMatrix(name,a,a.length,a[0].length);
  }
 else   if (t instanceof ComplexToken) {
    Complex[] a={((ComplexToken)t).complexValue()};
    ma=ptmatlabCreateComplexMatrixOneDim(name,a,a.length);
  }
 else {
    double[] a=new double[1];
    if (t instanceof BooleanToken) {
      a[0]=((BooleanToken)t).booleanValue() ? 1.0 : 0.0;
    }
 else {
      a[0]=((ScalarToken)t).doubleValue();
    }
    ma=ptmatlabCreateDoubleMatrixOneDim(name,a,1);
  }
  if (ma == 0) {
    throw new IllegalActionException("String_Node_Str" + name);
  }
  return ma;
}

Fixed version (ground truth):
private long _createMxArray(String name,Token t) throws IllegalActionException {
  long ma=0;
  if (t instanceof ArrayToken) {
    Token[] ta=((ArrayToken)t).arrayValue();
    if (!(ta[0] instanceof StringToken)) {
      ma=ptmatlabCreateCellMatrix(name,1,ta.length);
      if (ma == 0) {
        throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + name);
      }
      for (int n=0; n < ta.length; n++) {
        long fma=_createMxArray("String_Node_Str" + n + "String_Node_Str",ta[n]);
        if (fma == 0) {
          throw new IllegalActionException("String_Node_Str" + n + "String_Node_Str"+ name);
        }
        ptmatlabSetCell(name,ma,0,n,fma);
      }
    }
 else {
      String s=((StringToken)ta[0]).stringValue();
      ma=ptmatlabCreateString(name,s,ta.length,s.length());
      for (int n=1; n < ta.length; n++) {
        s=((StringToken)ta[n]).stringValue();
        ptmatlabSetString(name,ma,n,s,s.length());
      }
    }
  }
 else   if (t instanceof RecordToken) {
    Object[] fieldNames=(((RecordToken)t).labelSet()).toArray();
    ma=ptmatlabCreateStructMatrix(name,fieldNames,1,1);
    if (ma == 0) {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + name);
    }
    for (int n=0; n < fieldNames.length; n++) {
      Token f=((RecordToken)t).get((String)fieldNames[n]);
      long fma=_createMxArray((String)fieldNames[n],f);
      if (fma == 0) {
        throw new IllegalActionException("String_Node_Str" + fieldNames[n] + "String_Node_Str"+ name);
      }
      ptmatlabSetStructField(name,ma,(String)fieldNames[n],0,0,fma);
    }
  }
 else   if (t instanceof StringToken) {
    String s=((StringToken)t).stringValue();
    ma=ptmatlabCreateString(name,s,1,s.length());
  }
 else   if (t instanceof ComplexMatrixToken) {
    Complex[][] a=((ComplexMatrixToken)t).complexMatrix();
    ma=ptmatlabCreateComplexMatrix(name,a,a.length,a[0].length);
  }
 else   if (t instanceof MatrixToken) {
    double[][] a=((MatrixToken)t).doubleMatrix();
    ma=ptmatlabCreateDoubleMatrix(name,a,a.length,a[0].length);
  }
 else   if (t instanceof ComplexToken) {
    Complex[] a={((ComplexToken)t).complexValue()};
    ma=ptmatlabCreateComplexMatrixOneDim(name,a,a.length);
  }
 else {
    double[] a=new double[1];
    if (t instanceof BooleanToken) {
      a[0]=((BooleanToken)t).booleanValue() ? 1.0 : 0.0;
    }
 else     if (t instanceof BooleanToken) {
      a[0]=((ScalarToken)t).doubleValue();
    }
 else {
      throw new IllegalActionException("String_Node_Str" + t + "String_Node_Str"+ t.getType());
    }
    ma=ptmatlabCreateDoubleMatrixOneDim(name,a,1);
  }
  if (ma == 0) {
    throw new IllegalActionException("String_Node_Str" + name);
  }
  return ma;
}