Skip to content

Commit

Permalink
cleanup: avoid use after free
Browse files Browse the repository at this point in the history
  • Loading branch information
hanatos committed Jan 12, 2024
1 parent 0fcb7c6 commit f22458b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/gui/widget_recentcollect.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inline int
recently_used_collections()
{
ImGui::PushID("ruc");
int32_t ret = 0, num = CLAMP(dt_rc_get_int(&vkdt.rc, "gui/ruc_num", 0), 0, 10);
int32_t num = CLAMP(dt_rc_get_int(&vkdt.rc, "gui/ruc_num", 0), 0, 10);
for(int i=0;i<num;i++)
{
char entry[512];
Expand All @@ -18,13 +18,15 @@ recently_used_collections()
if(ImGui::Button(last, ImVec2(-1, 0)))
{
dt_gui_switch_collection(dir);
ret = 1;
ImGui::PopStyleVar(1);
ImGui::PopID();
return 0; // return immediately since switching collections invalidates dir (by sorting/compacting the gui/ruc_num entries)
}
if(ImGui::IsItemHovered())
dt_gui_set_tooltip("%s", dir);
ImGui::PopStyleVar(1);
}
}
ImGui::PopID();
return ret;
return 0;
}

0 comments on commit f22458b

Please sign in to comment.