Deleting images from a vector

Hi, I’m very new to openframeworks but have to do a project in which every time I replay a video (by pressing a button), certain frames are deleted so that it’s like it’s missing a clip.

I’ve tried capturing frames and placing them into a vector than using .erase to remove the frames but I keep getting EXC_BAD_ACCESS.

This is my code for deleting the parts of my image vector:
vector buff;

Buffer(){}

Buffer(int width, int height, ofImageType imgType, int size){
    
    head = 0;
    
    w = width;
    h = height;
    
    type = imgType;
    
    init = false;
    length = size;
    

    for(int i = 0; i< length; i++){
        
        buff.push_back(ofImage());
        buff[i].allocate(w,h,type);
        
    }
    
}

void addFrame(ofPixels p){
    
    buff[head].setFromPixels(p);

    head = (head + 1)%length;

    if (head == length - 1 && init == false){
        init = true;
    }
    
}



void deleteFrame(int x, int y, int width, int height){
    
    if(init == true){
        buff.erase(buff.begin()+5, buff.begin()+10);
        buff[head].draw(x, y, width, height);
    }
}

In “ofApp.cpp” I have this:

void ofApp::setup(){

ofBackground(0,0,0);

video.load("oldvid.mp4");

video.setLoopState(OF_LOOP_NONE);

video.getTotalNumFrames();


video.play();

remember = Button(750,330,234,58);

remember.onImage("rembutton.jpg");

buff = Buffer(600, 400, OF_IMAGE_COLOR, 600); }

void ofApp::update(){

video.update();
    if(video.isFrameNew()){
        buff.addFrame(video.getPixels());
    }

}

void ofApp::draw(){

remember.draw();

video.draw(60, 150, 600, 400);

if(remember.clicked == false){
    
}else{
    buff.deleteFrame(60, 150, 600, 400);
}


}

Logically, it makes sense to me. But it just crashes in the end after I press the button because of the EXC_BAD_ACCESS error.

So after the 5th frame, that is when the exception happens. But I don’t know why!!! All I want to do is delete a few frames and then show the video after.

It also says that it is “drawing an unallocated texture” so whatever that means.