Skip to content

Commit

Permalink
Prevent out-of-range values being used as translation string IDs in F…
Browse files Browse the repository at this point in the history
…loatingWindow::TranslatedComboAnimated()
  • Loading branch information
elvissteinjr committed Oct 25, 2024
1 parent 71755e2 commit 5ad168e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/DesktopPlusUI/FloatingWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1577,8 +1577,9 @@ const ImVec2& FloatingWindow::GetSize() const
bool FloatingWindow::TranslatedComboAnimated(const char* label, int& value, TRMGRStrID trstr_min, TRMGRStrID trstr_max)
{
bool ret = false;
const char* preview_value = ((trstr_min + value >= trstr_min) && (trstr_min + value <= trstr_max)) ? TranslationManager::GetString( (TRMGRStrID)(trstr_min + value) ) : "???";

if (ImGui::BeginComboAnimated(label, TranslationManager::GetString( (TRMGRStrID)(trstr_min + value) ) ))
if (ImGui::BeginComboAnimated(label, preview_value))
{
//Make use of the fact values and translation string IDs are laid out sequentially and shorten this to a nice loop
const int value_max = (trstr_max - trstr_min) + 1;
Expand Down

0 comments on commit 5ad168e

Please sign in to comment.