Skip to content

Commit

Permalink
Trying to fix file.AsyncRead reading memory????
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelIT7 committed Apr 5, 2024
1 parent 7fc650d commit 1f609a3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/library_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ void AsyncCallback(const FileAsyncRequest_t &request, int nBytesRead, FSAsyncSta
{
async->finished = true;
async->nBytesRead = nBytesRead;
async->content = new char[nBytesRead];
std::memcpy((void*)async->content, request.pData, nBytesRead);
char* content = new char[nBytesRead + 1];
std::memcpy(static_cast<void*>(content), request.pData, nBytesRead);
content[nBytesRead] = '\0';
async->content = content;
} else {
Msg("[Luathreaded] file.AsyncRead Invalid request?\n");
}
Expand Down

0 comments on commit 1f609a3

Please sign in to comment.