[Demonstration 1]

[Buggy Method]
protected void renderCrosshairs(int width, int height) {
    if (pre(CROSSHAIRS))
        return;
    if (this.showCrosshair()) {
        bind(Gui.icons);
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR, 1, 0);
        GlStateManager.enableAlpha();
        drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0, 0, 16, 16);
        GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
        GL11.glDisable(GL11.GL_BLEND);
    }
    post(CROSSHAIRS);
}

[Buggy Hunk]
GL11.glDisable(GL11.GL_BLEND);

[Patch]
GlStateManager.disableBlend();

[Demonstration 2]

[Buggy Method]
private void ensureCapacity(int minCapacity) {
    // If we have enough space, don't grow the buffer.
    if (minCapacity <= buffer.length) {
        return;
    }
    // Try to double the size of the buffer, if thats not enough, just use the new capacity.
    // Note that we use Math.min(long, long) to not cause overflow on the multiplication.
    int newCapacity = (int) Math.min(Integer.MAX_VALUE, buffer.length * 2L);
    if (newCapacity < minCapacity) {
        newCapacity = minCapacity;
    }
    buffer = Arrays.copyOf(buffer, newCapacity);
}

[Buggy Hunk]
int newCapacity = (int) Math.min(Integer.MAX_VALUE, buffer.length * 2L);

[Patch]
int newCapacity = (int) Math.min(Integer.MAX_VALUE - 2, buffer.length * 2L);

[Demonstration 3]

[Buggy Method]
@Override
public Object readValue(ReadContext context) {
    return context.readDouble();
}

[Buggy Hunk]
return context.readDouble();

[Patch]
return values[context.readInt()];