From e5d8be3271eeb806bde0f1d5ecdb53256284e555 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 17 Mar 2017 15:07:56 +0200 Subject: ubsan fix after "drop GetId() from SfxUndoAction" bug introduced by commit 64ea8306b0ceb001132ac9cbc945a12afc01b8cd drop GetId() from SfxUndoAction Change-Id: I75b23650c7dc15fc76fe1b9118129ff8ead35315 Reviewed-on: https://gerrit.libreoffice.org/35333 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/undo/docundo.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sw') diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx index ee674659ddce..22b1e2a0a9bb 100644 --- a/sw/source/core/undo/docundo.cxx +++ b/sw/source/core/undo/docundo.cxx @@ -385,7 +385,12 @@ UndoManager::GetLastUndoInfo( } if (o_pId) { - *o_pId = static_cast(pAction)->GetId(); + if (auto pListAction = dynamic_cast(pAction)) + *o_pId = (SwUndoId)pListAction->GetId(); + else if (auto pSwAction = dynamic_cast(pAction)) + *o_pId = pSwAction->GetId(); + else + *o_pId = SwUndoId::EMPTY; } return true; @@ -443,7 +448,12 @@ bool UndoManager::GetFirstRedoInfo(OUString *const o_pStr, } if (o_pId) { - *o_pId = static_cast(pAction)->GetId(); + if (auto pListAction = dynamic_cast(pAction)) + *o_pId = (SwUndoId)pListAction->GetId(); + else if (auto pSwAction = dynamic_cast(pAction)) + *o_pId = pSwAction->GetId(); + else + *o_pId = SwUndoId::EMPTY; } return true; -- cgit