[Demonstration 1]

[Buggy Method]
private void doSendBack() {
    if (imageSender != null) {
        imageSender.sendBack(senderDataId, resultCanvas.toDataUrl());
        manager.selectTab(3);
    } else {
        LogUtils.log("no imageSender");
    }
}

[Buggy Hunk]
imageSender.sendBack(senderDataId, resultCanvas.toDataUrl());

[Patch]
imageSender.sendBack(senderDataId, ImageDataUtils.copyFrom(resultCanvas));

[Demonstration 2]

[Buggy Method]
public static void fireEvent(Event event) {
    if (!EventControlPanel.stop) {
        EventControlPanel.events.offer(event);
    }
}

[Buggy Hunk]
if (!EventControlPanel.stop)

[Patch]
if (EventControlPanel.masterEventHandler.running)

[Demonstration 3]

[Buggy Method]
public void animationPass() throws ParseException, IOException {
    // Ensure isAnimated is set to false beforehand
    isAnimated = false;
    checkForAnimation();
    if (!isAnimated) {
        numFrames = 1;
        return;
    }
    // Error check
    if (numFrames == -1) {
        throwError("Number of frames for animation not set");
    }
    if (basename.length() == 0) {
        throwError("Animation frame / image file basename not set");
    }
    // Get knob values
    for (OPCode opc : opcodes) {
        if (opc instanceof OPVary) {
            Double[] knobValues = knobs.get(((OPVary) opc).getKnob());
            // Create the knob values if not yet created
            if (knobValues == null) {
                knobValues = new Double[numFrames];
            }
            int start = ((OPVary) opc).getStartframe();
            int end = ((OPVary) opc).getEndframe();
            double startVal = ((OPVary) opc).getStartval();
            double endVal = ((OPVary) opc).getEndval();
            // Throw error if start frame is not within bounds
            if (start < 0 || end >= numFrames) {
                throwError("Frame start or end [" + ((OPVary) opc).getKnob() + "] is out of bounds");
            }
            for (int frame = start; frame <= end; frame++) {
                knobValues[frame] = startVal;
                // Add rate of change:
                startVal += (endVal - startVal) / (end - start + 1);
            }
            knobs.put(((OPVary) opc).getKnob(), knobValues);
        }
    }
    PPMGenerator.setUpOutputDirectory(basename);
    int numberLength = Integer.toString(numFrames).length();
    formatString = basename + "/" + basename + "-%0" + numberLength + "d.ppm";
}

[Buggy Hunk]
startVal += (endVal - startVal) / (end - start + 1);

[Patch]
startVal += (endVal - startVal) / ((double) end - (double) start + 1);