[code] Fix EditorController: cannot use strcpy when the first char is a

flag that can be 0
This commit is contained in:
Émilie Feral
2018-10-08 09:25:52 +02:00
committed by LeaNumworks
parent 3677b2f1d0
commit 625c0acd8b

View File

@@ -22,7 +22,8 @@ void EditorController::setScript(Script script) {
Script::Data scriptData = m_script.value();
size_t availableScriptSize = scriptData.size + Ion::Storage::sharedStorage()->availableSize();
assert(sizeof(m_areaBuffer) >= availableScriptSize);
strlcpy(m_areaBuffer, (const char *)scriptData.buffer, scriptData.size);
// We cannot use strlcpy as the first char reprensenting the importation status can be 0.
memcpy(m_areaBuffer, (const char *)scriptData.buffer, scriptData.size);
m_editorView.setText(m_areaBuffer+1, availableScriptSize-1); // 1 char is taken by the importation status flag
}