Program: 24539
Project: 24539
Buggy source:
private void parse(){
  try {
    arguments=new ArrayList<String>();
    envVars=new HashMap<String,String>();
class StringArrayMemory extends Memory {
      private long offset=0;
      StringArrayMemory(      long l){
        super(l);
      }
      int readInt(){
        int r=getInt(offset);
        offset+=sizeOfInt;
        return r;
      }
      boolean hasMore(){
        return offset < getSize();
      }
      byte peek(){
        return getByte(offset);
      }
      String readString(){
        ByteArrayOutputStream baos=new ByteArrayOutputStream();
        byte ch;
        while (hasMore() && (ch=getByte(offset++)) != '\0') {
          baos.write(ch);
        }
        return baos.toString();
      }
      void skip0(){
        while (getByte(offset) == '\0') {
          offset++;
        }
      }
    }
    IntByReference newSize=new IntByReference();
    IntByReference size=new IntByReference(sizeOfInt);
    if (LIBC.sysctl(new int[]{CTL_KERN,KERN_PROCARGS2,pid},3,NULL,size,NULL,newSize) != 0) {
      throw new IOException("String_Node_Str" + LIBC.strerror(Native.getLastError()));
    }
    size.setValue(size.getValue() + 1);
    StringArrayMemory m=new StringArrayMemory(size.getValue());
    if (LIBC.sysctl(new int[]{CTL_KERN,KERN_PROCARGS2,pid},3,m,size,NULL,newSize) != 0) {
      throw new IOException("String_Node_Str" + LIBC.strerror(Native.getLastError()));
    }
    int nargs=m.readInt();
    m.readString();
    for (int i=0; i < nargs; i++) {
      m.skip0();
      arguments.add(m.readString());
    }
    while (m.hasMore() && m.peek() != 0) {
      String line=m.readString();
      int sep=line.indexOf('=');
      if (sep > 0) {
        envVars.put(line.substring(0,sep),line.substring(sep + 1));
      }
    }
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
private void parse(){
  final int sizeOfInt=Native.getNativeSize(int.class);
  try {
    arguments=new ArrayList<String>();
    envVars=new HashMap<String,String>();
class StringArrayMemory extends Memory {
      private long offset=0;
      StringArrayMemory(      long l){
        super(l);
      }
      int readInt(){
        int r=getInt(offset);
        offset+=sizeOfInt;
        return r;
      }
      boolean hasMore(){
        return offset < getSize();
      }
      byte peek(){
        return getByte(offset);
      }
      String readString(){
        ByteArrayOutputStream baos=new ByteArrayOutputStream();
        byte ch;
        while (hasMore() && (ch=getByte(offset++)) != '\0') {
          baos.write(ch);
        }
        return baos.toString();
      }
      void skip0(){
        while (getByte(offset) == '\0') {
          offset++;
        }
      }
    }
    IntByReference newSize=new IntByReference();
    IntByReference size=new IntByReference(sizeOfInt);
    if (LIBC.sysctl(new int[]{CTL_KERN,KERN_PROCARGS2,pid},3,NULL,size,NULL,newSize) != 0) {
      throw new IOException("String_Node_Str" + LIBC.strerror(Native.getLastError()));
    }
    size.setValue(size.getValue() + 1);
    StringArrayMemory m=new StringArrayMemory(size.getValue());
    if (LIBC.sysctl(new int[]{CTL_KERN,KERN_PROCARGS2,pid},3,m,size,NULL,newSize) != 0) {
      throw new IOException("String_Node_Str" + LIBC.strerror(Native.getLastError()));
    }
    int nargs=m.readInt();
    m.readString();
    for (int i=0; i < nargs; i++) {
      m.skip0();
      arguments.add(m.readString());
    }
    while (m.hasMore() && m.peek() != 0) {
      String line=m.readString();
      int sep=line.indexOf('=');
      if (sep > 0) {
        envVars.put(line.substring(0,sep),line.substring(sep + 1));
      }
    }
  }
 catch (  IOException e) {
  }
}