sw/source/core/doc/docdesc.cxx | 3 --- sw/source/uibase/shells/basesh.cxx | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-)
New commits: commit c3a0f570ece7799166d8b21dc7c7417fa6b19ec6 Author: Daniel Arato (NISZ) <arato.dan...@nisz.hu> AuthorDate: Mon Apr 26 15:04:17 2021 +0200 Commit: Tünde Tóth <toth.tu...@nisz.hu> CommitDate: Thu Oct 21 13:11:15 2021 +0200 tdf#141613 sw: avoid possible crash when undoing header creation Move the ClearRedo() call to the very end of the undo process in order to avoid heap use after free. We still need to call ClearRedo() because there's no mechanism in place to Redo a header/footer change. Regression from commit 65e52cb61d74b0c71b45b63b2da131bc6b621104 "tdf#141613 sw: fix crash at header/footer undo". Change-Id: Ibd4604379c9791e85aef3d4dc6c29c9e3ecd5a28 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115275 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 0cd000bb83719982c1fd2265ea040c82af5bf98e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123977 Tested-by: Tünde Tóth <toth.tu...@nisz.hu> Reviewed-by: Tünde Tóth <toth.tu...@nisz.hu> diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index 164404ce3016..d94f23b87fcb 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -498,9 +498,6 @@ void SwDoc::ChgPageDesc( size_t i, const SwPageDesc &rChged ) lDelHFFormat(&rDescLeftFooterFormat, rDescLeftFooterFormat.GetFooterFormat()); else if (rDescFirstLeftFooterFormat.GetFooterFormat() && rDescFirstLeftFooterFormat != rChgedFirstLeftFooterFormat) lDelHFFormat(&rDescFirstLeftFooterFormat, rDescFirstLeftFooterFormat.GetFooterFormat()); - - // FIXME: Disable redoing this change until we figure out how - GetIDocumentUndoRedo().ClearRedo(); } } ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 359dea043183..8d774615522e 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -557,6 +557,12 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq) rWrtShell.Do( SwWrtShell::UNDO, nCnt ); for (SwViewShell& rShell : rWrtShell.GetRingContainer()) rShell.UnlockPaint(); + + // tdf#141613 FIXME: Disable redoing header/footer changes for now. + // The proper solution would be to write a SwUndoHeaderFooter class + // to represent the addition of a header or footer to the current page. + if (nUndoId == SwUndoId::HEADER_FOOTER) + rUndoRedo.ClearRedo(); } break;