lib/file:Fix issue #71 (Out of Bounds access)
parent
78880e1c20
commit
42b7e40f9d
|
@ -187,7 +187,7 @@ ErrorOrVoid File::insertByte(uint8_t byte){
|
||||||
this->fileStream.seekg(0);
|
this->fileStream.seekg(0);
|
||||||
this->write(readData);
|
this->write(readData);
|
||||||
this->cursorPosition++;
|
this->cursorPosition++;
|
||||||
delete buffer;
|
delete[] buffer;
|
||||||
}catch(std::exception& e){
|
}catch(std::exception& e){
|
||||||
failure = true;
|
failure = true;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ ErrorOrVoid File::insert(std::vector<uint8_t> data){
|
||||||
this->fileStream.seekg(0);
|
this->fileStream.seekg(0);
|
||||||
this->write(readData);
|
this->write(readData);
|
||||||
this->cursorPosition += data.size();
|
this->cursorPosition += data.size();
|
||||||
delete buffer;
|
delete[] buffer;
|
||||||
}catch(std::exception& e){
|
}catch(std::exception& e){
|
||||||
failure = true;
|
failure = true;
|
||||||
}
|
}
|
||||||
|
@ -230,10 +230,9 @@ ErrorOrVoid File::insertString(tiny_utf8::string string){
|
||||||
|
|
||||||
this->fileStream.seekg(0);
|
this->fileStream.seekg(0);
|
||||||
|
|
||||||
//TODO: fix hack. tinyutf8 appends "_utf-8" when readData is assigned: tiny_utf8::string((char *) buffer);
|
this->writeString(readData);
|
||||||
this->writeString(readData.substr(0, readData.find("_utf-8")));
|
|
||||||
this->cursorPosition += string.size();
|
this->cursorPosition += string.size();
|
||||||
delete buffer;
|
delete[] buffer;
|
||||||
}catch(std::exception& e){
|
}catch(std::exception& e){
|
||||||
failure = true;
|
failure = true;
|
||||||
}
|
}
|
||||||
|
@ -257,7 +256,7 @@ ErrorOr<uint8_t> File::cutByte(){
|
||||||
this->fileStream.seekg(0);
|
this->fileStream.seekg(0);
|
||||||
this->write(readData);
|
this->write(readData);
|
||||||
this->cursorPosition++;
|
this->cursorPosition++;
|
||||||
delete buffer;
|
delete[] buffer;
|
||||||
}catch(std::exception& e){
|
}catch(std::exception& e){
|
||||||
failure = true;
|
failure = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue