Program: 11638
Project: 11638
Buggy source:
protected void updateVertices(GL gl,LoadedGroup loaded,Group group,boolean fill){
  boolean initialized=fill ? loaded.glFillBufferInitialized : loaded.glLineBufferInitialized;
  int maxSize=fill ? loaded.glFillBufferMaxSize : loaded.glLineBufferMaxSize;
  int currentSize=fill ? loaded.glFillBufferCurrentSize : loaded.glLineBufferCurrentSize;
  int insertSize=fill ? group.fillInsertVertexCount : group.lineInsertVertexCount;
  int totalSize=fill ? group.totalFillVertexCount : group.totalLineVertexCount;
  int handle=fill ? loaded.glFillBufferHandle : loaded.glLineBufferHandle;
  int sizeNeeded=currentSize + insertSize;
  if (!initialized || maxSize < sizeNeeded) {
    if (!initialized || maxSize < DELETE_EXPAND_FACTOR * totalSize) {
      if (initialized) {
        gl.glDeleteBuffers(1,new int[]{handle},0);
        maxSize=Math.max((int)(maxSize * 1.5),totalSize);
      }
 else {
        maxSize=totalSize;
      }
      int[] bufferHandle=new int[1];
      gl.glGenBuffers(1,bufferHandle,0);
      handle=bufferHandle[0];
    }
    ensureDataBufferSize(maxSize);
    if (fill) {
      loaded.loadFillVerticesIntoBuffer(group,dataBuffer,0,group.polygonMap.values());
    }
 else {
      loaded.loadLineVerticesIntoBuffer(group,dataBuffer,0,group.polygonMap.values());
    }
    gl.glBindBuffer(GL.GL_ARRAY_BUFFER,handle);
    glHandleError(gl,"String_Node_Str");
    gl.glBufferData(GL.GL_ARRAY_BUFFER,maxSize * 3 * BYTES_PER_FLOAT,dataBuffer.rewind(),GL.GL_DYNAMIC_DRAW);
    glHandleError(gl,"String_Node_Str");
    if (fill) {
      loaded.glFillBufferInitialized=true;
      loaded.glFillBufferCurrentSize=totalSize;
      loaded.glFillBufferHandle=handle;
      loaded.glFillBufferMaxSize=maxSize;
    }
 else {
      loaded.glLineBufferInitialized=true;
      loaded.glLineBufferCurrentSize=totalSize;
      loaded.glLineBufferHandle=handle;
      loaded.glLineBufferMaxSize=maxSize;
    }
  }
 else {
    int insertVertices=insertSize;
    ensureDataBufferSize(insertVertices);
    if (fill) {
      loaded.loadFillVerticesIntoBuffer(group,dataBuffer,currentSize,group.newPolygons);
    }
 else {
      loaded.loadLineVerticesIntoBuffer(group,dataBuffer,currentSize,group.newPolygons);
    }
    gl.glBindBuffer(GL.GL_ARRAY_BUFFER,handle);
    glHandleError(gl,"String_Node_Str");
    gl.glBufferSubData(GL.GL_ARRAY_BUFFER,currentSize * 3 * BYTES_PER_FLOAT,insertVertices * 3 * BYTES_PER_FLOAT,dataBuffer.rewind());
    glHandleError(gl,"String_Node_Str");
    if (fill) {
      loaded.glFillBufferCurrentSize=sizeNeeded;
    }
 else {
      loaded.glLineBufferCurrentSize=sizeNeeded;
    }
  }
}

Fixed version (ground truth):
protected void updateVertices(GL gl,LoadedGroup loaded,Group group,boolean fill){
  boolean initialized=fill ? loaded.glFillBufferInitialized : loaded.glLineBufferInitialized;
  int maxSize=fill ? loaded.glFillBufferMaxSize : loaded.glLineBufferMaxSize;
  int currentSize=fill ? loaded.glFillBufferCurrentSize : loaded.glLineBufferCurrentSize;
  int insertSize=fill ? group.fillInsertVertexCount : group.lineInsertVertexCount;
  int totalSize=fill ? group.totalFillVertexCount : group.totalLineVertexCount;
  int handle=fill ? loaded.glFillBufferHandle : loaded.glLineBufferHandle;
  int sizeNeeded=currentSize + insertSize;
  if (!initialized || maxSize < sizeNeeded) {
    if (!initialized || maxSize < DELETE_EXPAND_FACTOR * totalSize) {
      if (initialized) {
        gl.glDeleteBuffers(1,new int[]{handle},0);
        maxSize=Math.max((int)(maxSize * 1.5),totalSize);
      }
 else {
        maxSize=totalSize;
      }
      int[] bufferHandle=new int[1];
      gl.glGenBuffers(1,bufferHandle,0);
      handle=bufferHandle[0];
      if (fill)       System.out.println("String_Node_Str" + maxSize);
    }
    ensureDataBufferSize(maxSize);
    if (fill) {
      loaded.loadFillVerticesIntoBuffer(group,dataBuffer,0,group.polygonMap.values());
      loaded.loadFillSelectionIntoBuffer(group.selectedPolygons,group.selectedFillPrimitiveCount,0);
    }
 else {
      loaded.loadLineVerticesIntoBuffer(group,dataBuffer,0,group.polygonMap.values());
      loaded.loadLineSelectionIntoBuffer(group.selectedPolygons,group.selectedLinePrimitiveCount,0);
    }
    gl.glBindBuffer(GL.GL_ARRAY_BUFFER,handle);
    glHandleError(gl,"String_Node_Str");
    gl.glBufferData(GL.GL_ARRAY_BUFFER,maxSize * 3 * BYTES_PER_FLOAT,dataBuffer.rewind(),GL.GL_DYNAMIC_DRAW);
    glHandleError(gl,"String_Node_Str");
    if (fill) {
      loaded.glFillBufferInitialized=true;
      loaded.glFillBufferCurrentSize=totalSize;
      loaded.glFillBufferHandle=handle;
      loaded.glFillBufferMaxSize=maxSize;
    }
 else {
      loaded.glLineBufferInitialized=true;
      loaded.glLineBufferCurrentSize=totalSize;
      loaded.glLineBufferHandle=handle;
      loaded.glLineBufferMaxSize=maxSize;
    }
  }
 else {
    ensureDataBufferSize(insertSize);
    if (fill) {
      loaded.loadFillVerticesIntoBuffer(group,dataBuffer,currentSize,group.newPolygons);
      loaded.loadFillSelectionIntoBuffer(group.newSelectedPolygons,group.selectedFillPrimitiveCount);
    }
 else {
      loaded.loadLineVerticesIntoBuffer(group,dataBuffer,currentSize,group.newPolygons);
      loaded.loadLineSelectionIntoBuffer(group.newSelectedPolygons,group.selectedLinePrimitiveCount);
    }
    gl.glBindBuffer(GL.GL_ARRAY_BUFFER,handle);
    glHandleError(gl,"String_Node_Str");
    gl.glBufferSubData(GL.GL_ARRAY_BUFFER,currentSize * 3 * BYTES_PER_FLOAT,insertSize * 3 * BYTES_PER_FLOAT,dataBuffer.rewind());
    glHandleError(gl,"String_Node_Str");
    if (fill) {
      loaded.glFillBufferCurrentSize=sizeNeeded;
    }
 else {
      loaded.glLineBufferCurrentSize=sizeNeeded;
    }
  }
}