lib/file:Fix issue #71 (Out of Bounds access)

windows
Shwoomple 2022-11-12 10:58:27 +05:30 committed by BodgeMaster
parent 78880e1c20
commit 42b7e40f9d
1 changed files with 5 additions and 6 deletions

View File

@ -187,7 +187,7 @@ ErrorOrVoid File::insertByte(uint8_t byte){
this->fileStream.seekg(0);
this->write(readData);
this->cursorPosition++;
delete buffer;
delete[] buffer;
}catch(std::exception& e){
failure = true;
}
@ -209,7 +209,7 @@ ErrorOrVoid File::insert(std::vector<uint8_t> data){
this->fileStream.seekg(0);
this->write(readData);
this->cursorPosition += data.size();
delete buffer;
delete[] buffer;
}catch(std::exception& e){
failure = true;
}
@ -230,10 +230,9 @@ ErrorOrVoid File::insertString(tiny_utf8::string string){
this->fileStream.seekg(0);
//TODO: fix hack. tinyutf8 appends "_utf-8" when readData is assigned: tiny_utf8::string((char *) buffer);
this->writeString(readData.substr(0, readData.find("_utf-8")));
this->writeString(readData);
this->cursorPosition += string.size();
delete buffer;
delete[] buffer;
}catch(std::exception& e){
failure = true;
}
@ -257,7 +256,7 @@ ErrorOr<uint8_t> File::cutByte(){
this->fileStream.seekg(0);
this->write(readData);
this->cursorPosition++;
delete buffer;
delete[] buffer;
}catch(std::exception& e){
failure = true;
}