From 3f70e153eedc59cbeea9e9bdb7a55242fced1eeb Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Sat, 27 Mar 2004 13:24:16 +0000 Subject: [PATCH] Ensure that insetlist always contains non-null pointers to insets. Fix a couple of possible memory leaks. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8546 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 +++++ src/paragraph_funcs.C | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index b3ed0d7a83..8ca0c1cf0b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-03-27 Angus Leeming + + * paragraph_funcs.C (moveItem): fix memory leaks, ensure that + insetlist always contains non-null pointers to insets. + 2004-03-26 Angus Leeming * src/BufferView_pimpl.C: diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index 05fe823984..ff7d32fd01 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -68,11 +68,15 @@ bool moveItem(Paragraph & from, Paragraph & to, if (from.getInset(i)) { // the inset is not in a paragraph anymore tmpinset = from.insetlist.release(i); + from.insetlist.erase(i); } - if (!to.insetAllowed(tmpinset->lyxCode())) + if (!to.insetAllowed(tmpinset->lyxCode())) { + delete tmpinset; return false; - to.insertInset(j, tmpinset, tmpfont); + } + if (tmpinset) + to.insertInset(j, tmpinset, tmpfont); } else { if (!to.checkInsertChar(tmpfont)) return false; -- 2.39.2