From 93cea86312f191403b45a165859a017253204543 Mon Sep 17 00:00:00 2001 From: bank Date: Mon, 24 Apr 2023 13:41:19 +0300 Subject: [PATCH] Fix buffer overflow in GuiTreeViewCtrl class. When calculating test length (in method `GuiTreeViewCtrl::Item::getDisplayTextLength()`) the code doesn't take into account the `ItemState::Marked`, which adds additional char in `GuiTreeViewCtrl::Item::getDisplayText()` method. This commit fixes warning printed into console when calling `dSprintf()` as the buffer is now enough to fit all data. --- Engine/source/gui/controls/guiTreeViewCtrl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Engine/source/gui/controls/guiTreeViewCtrl.cpp b/Engine/source/gui/controls/guiTreeViewCtrl.cpp index fa6a6f73b..e9e01a8bf 100644 --- a/Engine/source/gui/controls/guiTreeViewCtrl.cpp +++ b/Engine/source/gui/controls/guiTreeViewCtrl.cpp @@ -466,6 +466,10 @@ U32 GuiTreeViewCtrl::Item::getDisplayTextLength() if( internalName && internalName[ 0 ] ) len += dStrlen( internalName ) + 3; // ' []' } + if( mState.test( Marked ) ) + { + len += 1; // '*' + } return len; }