Program: 109170
Project: 109170
Buggy source:
protected void update(){
  if (!initialized) {
    String ext=GLES20.glGetString(GLES20.GL_EXTENSIONS);
    if (-1 < ext.indexOf("String_Node_Str")) {
      fboWidth=pg.width;
      fboHeight=pg.height;
    }
 else {
      fboWidth=PGL.nextPowerOfTwo(pg.width);
      fboHeight=PGL.nextPowerOfTwo(pg.height);
    }
    boolean packed=ext.indexOf("String_Node_Str") != -1;
    GLES20.glGenTextures(2,glColorTex,0);
    for (int i=0; i < 2; i++) {
      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,glColorTex[i]);
      GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_NEAREST);
      GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MAG_FILTER,GLES20.GL_NEAREST);
      GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_S,GLES20.GL_CLAMP_TO_EDGE);
      GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_T,GLES20.GL_CLAMP_TO_EDGE);
      GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D,0,GLES20.GL_RGBA,fboWidth,fboHeight,0,PGL.RGBA,PGL.UNSIGNED_BYTE,null);
      initTexture(GLES20.GL_TEXTURE_2D,PGL.RGBA,fboWidth,fboHeight);
    }
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,0);
    GLES20.glGenFramebuffers(1,glColorFbo,0);
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,glColorFbo[0]);
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,glColorTex[0],0);
    if (packed) {
      int[] depthStencil={0};
      GLES20.glGenRenderbuffers(1,depthStencil,0);
      GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,depthStencil[0]);
      GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,DEPTH24_STENCIL8,fboWidth,fboHeight);
      GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT,GLES20.GL_RENDERBUFFER,depthStencil[0]);
      GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_STENCIL_ATTACHMENT,GLES20.GL_RENDERBUFFER,depthStencil[0]);
    }
 else {
      int[] depth={0};
      int[] stencil={0};
      GLES20.glGenRenderbuffers(1,depth,0);
      GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,depth[0]);
      GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,GLES20.GL_DEPTH_COMPONENT16,fboWidth,fboHeight);
      GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT,GLES20.GL_RENDERBUFFER,depth[0]);
      int[] temp=new int[1];
      GLES20.glGetIntegerv(GLES20.GL_STENCIL_BITS,temp,0);
      int stencilBits=temp[0];
      if (stencilBits == 8) {
        GLES20.glGenRenderbuffers(1,stencil,0);
        GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,stencil[0]);
        GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,GLES20.GL_STENCIL_INDEX8,fboWidth,fboHeight);
        GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_STENCIL_ATTACHMENT,GLES20.GL_RENDERBUFFER,stencil[0]);
      }
    }
    validateFramebuffer();
    GLES20.glClearDepthf(1);
    GLES20.glClearStencil(0);
    GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_STENCIL_BUFFER_BIT);
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0);
    PGraphicsOpenGL.drawFramebuffer.glFbo=0;
    backTex=0;
    frontTex=1;
    initialized=true;
  }
}

Fixed version (ground truth):
protected void update(){
  if (!initialized) {
    String ext=GLES20.glGetString(GLES20.GL_EXTENSIONS);
    if (-1 < ext.indexOf("String_Node_Str")) {
      fboWidth=pg.width;
      fboHeight=pg.height;
    }
 else {
      fboWidth=PGL.nextPowerOfTwo(pg.width);
      fboHeight=PGL.nextPowerOfTwo(pg.height);
    }
    boolean packed=ext.indexOf("String_Node_Str") != -1;
    int depthBits=getDepthBits();
    int stencilBits=getStencilBits();
    GLES20.glGenTextures(2,glColorTex,0);
    for (int i=0; i < 2; i++) {
      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,glColorTex[i]);
      GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_NEAREST);
      GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MAG_FILTER,GLES20.GL_NEAREST);
      GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_S,GLES20.GL_CLAMP_TO_EDGE);
      GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_T,GLES20.GL_CLAMP_TO_EDGE);
      GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D,0,GLES20.GL_RGBA,fboWidth,fboHeight,0,PGL.RGBA,PGL.UNSIGNED_BYTE,null);
      initTexture(GLES20.GL_TEXTURE_2D,PGL.RGBA,fboWidth,fboHeight);
    }
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,0);
    backTex=0;
    frontTex=1;
    GLES20.glGenFramebuffers(1,glColorFbo,0);
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,glColorFbo[0]);
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,glColorTex[backTex],0);
    if (packed && depthBits == 24 && stencilBits == 8) {
      int[] depthStencil={0};
      GLES20.glGenRenderbuffers(1,depthStencil,0);
      GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,depthStencil[0]);
      GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,DEPTH24_STENCIL8,fboWidth,fboHeight);
      GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT,GLES20.GL_RENDERBUFFER,depthStencil[0]);
      GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_STENCIL_ATTACHMENT,GLES20.GL_RENDERBUFFER,depthStencil[0]);
    }
 else {
      int[] depth={0};
      int[] stencil={0};
      GLES20.glGenRenderbuffers(1,depth,0);
      GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,depth[0]);
      GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,GLES20.GL_DEPTH_COMPONENT16,fboWidth,fboHeight);
      GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT,GLES20.GL_RENDERBUFFER,depth[0]);
      if (stencilBits == 8) {
        GLES20.glGenRenderbuffers(1,stencil,0);
        GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,stencil[0]);
        GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,GLES20.GL_STENCIL_INDEX8,fboWidth,fboHeight);
        GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_STENCIL_ATTACHMENT,GLES20.GL_RENDERBUFFER,stencil[0]);
      }
    }
    validateFramebuffer();
    GLES20.glClearDepthf(1);
    GLES20.glClearStencil(0);
    GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_STENCIL_BUFFER_BIT);
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0);
    initialized=true;
  }
}