From 7cad778cc08d8c9f1f9965d6aca024f8bfecae0a Mon Sep 17 00:00:00 2001 From: Satya Date: Fri, 15 Mar 2019 09:51:17 +0530 Subject: [PATCH] Fix memory leak (#300) Free memory allocated to temp before returning from the function. --- src/CalcViewModel/StandardCalculatorViewModel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp index b035c14c..a95199b9 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -558,6 +558,7 @@ void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum) length = m_selectedExpressionLastData->Length() + 1; if (length > 50) { + delete [] temp; return; } for (; i < length; ++i)