Skip to content

Commit 9e01278

Browse files
committed
Do not copy project.json to string when loading projects
1 parent f909542 commit 9e01278

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/internal/scratch3reader.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,11 @@ void Scratch3Reader::read()
562562
if (m_zipReader->open()) {
563563
// Parse the JSON
564564
try {
565-
std::string jsonStr;
566-
m_zipReader->readFileToString("project.json", jsonStr);
567-
m_json = json::parse(jsonStr);
565+
char *buf;
566+
const size_t size = m_zipReader->readFile("project.json", (void **)&buf);
567+
assert(buf);
568+
m_json = json::parse(buf, buf + size);
569+
free(buf);
568570
} catch (std::exception &e) {
569571
printErr("invalid JSON file", e.what());
570572
}

0 commit comments

Comments
 (0)