summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2021-09-30 14:10:12 +0200
committerVasily Melenchuk <vasily.melenchuk@cib.de>2021-10-01 09:02:46 +0200
commitbf4cb13c7b3b57980d8e052c1b06afc3f21b96f2 (patch)
tree7486bfebbd97c255053b5e01e09b2d9fa1fee336 /sc
parent955ccb669c60cc29918c784d9c801ab1ac54fc22 (diff)
sc: colorfilter dangling pointer fixed
Upper call to aParam.RemoveAllEntriesByField can invalidate pEntry, making further calls to pEntry->SetQueryBy* illegal. Anyway at this branch we are disabling color filter, so this is not required. Change-Id: Ia595649975b659d28056ba3f3658c306e63088f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122822 Tested-by: Jenkins Reviewed-by: Vasily Melenchuk <vasily.melenchuk@cib.de>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/view/gridwin.cxx21
1 files changed, 12 insertions, 9 deletions
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 8e7bfff9d09e..4f65327b4a4d 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -970,6 +970,7 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
if (nSelected == nActive)
{
aParam.RemoveAllEntriesByField(rPos.Col());
+ pEntry = nullptr; // invalidated by RemoveAllEntriesByField call
// tdf#46184 reset filter options to default values
aParam.eSearchType = utl::SearchParam::SearchType::Normal;
@@ -977,16 +978,18 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
aParam.bDuplicate = true;
aParam.bInplace = true;
}
-
- // Get selected color from set
- std::set<Color>::iterator it = aColors.begin();
- std::advance(it, nSelected - 1);
- Color selectedColor = *it;
-
- if (eMode == AutoFilterMode::TextColor)
- pEntry->SetQueryByTextColor(selectedColor);
else
- pEntry->SetQueryByBackgroundColor(selectedColor);
+ {
+ // Get selected color from set
+ std::set<Color>::iterator it = aColors.begin();
+ std::advance(it, nSelected - 1);
+ Color selectedColor = *it;
+
+ if (eMode == AutoFilterMode::TextColor)
+ pEntry->SetQueryByTextColor(selectedColor);
+ else
+ pEntry->SetQueryByBackgroundColor(selectedColor);
+ }
}
break;