Commit a3e9ed47 authored by salix5's avatar salix5 Committed by GitHub

Fix memory allocation for data buffer (#2940)

Removed null terminator allocation for memory data.
parent 3df874cc
......@@ -89,10 +89,9 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
spmembuffer_t* mem = (spmembuffer_t*)std::calloc(sizeof(spmembuffer_t), 1);
spmemvfs_env_init();
mem->total = mem->used = reader->getSize();
mem->data = (char*)std::malloc(mem->total + 1);
mem->data = (char*)std::malloc(mem->total);
reader->read(mem->data, mem->total);
reader->drop();
(mem->data)[mem->total] = '\0';
bool ret{};
if (spmemvfs_open_db(&db, file, mem) != SQLITE_OK)
ret = Error(db.handle);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment