From 7e9b4c1a609370a3e17801c36b4a4f9b94cfc9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 17 May 2018 15:09:47 +0200 Subject: [PATCH] [apps/code] Fix buffer indexes Change-Id: Ib5748d59fd762af9337e00115f0db4ac5d6d08a9 --- apps/code/console_store.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/code/console_store.cpp b/apps/code/console_store.cpp index e23135b1f..1d238f0e0 100644 --- a/apps/code/console_store.cpp +++ b/apps/code/console_store.cpp @@ -113,7 +113,7 @@ void ConsoleStore::push(const char marker, const char * text, size_t length) { } m_history[i] = marker; strlcpy(&m_history[i+1], text, textLength+1); - m_history[i+1+length+1] = 0; + m_history[i+1+textLength+1] = 0; } ConsoleLine::Type ConsoleStore::lineTypeForMarker(char marker) const { @@ -148,6 +148,9 @@ void ConsoleStore::deleteLineAtIndex(int index) { nextLineStart++; } nextLineStart++; + if (nextLineStart > k_historySize - 1) { + return; + } memmove(&m_history[i], &m_history[nextLineStart], (k_historySize - 1) - nextLineStart + 1); return; }