From 8a3bd28c92779a1408eb9fff84655f7e026b91d1 Mon Sep 17 00:00:00 2001 From: nakst <> Date: Fri, 26 Nov 2021 10:43:00 +0000 Subject: [PATCH] fix text editor crash --- apps/text_editor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/text_editor.cpp b/apps/text_editor.cpp index 7b26ec1..92f9cd0 100644 --- a/apps/text_editor.cpp +++ b/apps/text_editor.cpp @@ -406,7 +406,9 @@ void ProcessApplicationMessage(EsMessage *message) { void _start() { _init(); - EsINIState state = { (char *) EsFileReadAll(EsLiteral(SETTINGS_FILE), &state.bytes) }; + size_t settingsFileBytes = 0; + char *settingsFile = (char *) EsFileReadAll(EsLiteral(SETTINGS_FILE), &settingsFileBytes); + EsINIState state = { .buffer = settingsFile, .bytes = settingsFileBytes }; while (EsINIParse(&state)) { if (0 == EsStringCompareRaw(state.section, state.sectionBytes, EsLiteral("general"))) { @@ -416,7 +418,7 @@ void _start() { } } - EsHeapFree(state.buffer); + EsHeapFree(settingsFile); while (true) { ProcessApplicationMessage(EsMessageReceive());