diff --git a/src/lib/file.cpp b/src/lib/file.cpp index acb8e38..b5ca0c5 100644 --- a/src/lib/file.cpp +++ b/src/lib/file.cpp @@ -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 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 File::cutByte(){ this->fileStream.seekg(0); this->write(readData); this->cursorPosition++; - delete buffer; + delete[] buffer; }catch(std::exception& e){ failure = true; }