diff options
author | Tomas Janousek <tomi@nomi.cz> | 2008-02-05 17:31:15 (GMT) |
---|---|---|
committer | Tomas Janousek <tomi@nomi.cz> | 2008-02-06 15:40:46 (GMT) |
commit | 3a8ec6512bee89ac495891665fc40bf1d893a389 (patch) | |
tree | 351971c200ae7bb876395fd91d484dae6efc7c8c | |
parent | 1534c8d728d6fd2f97feef5e0a5f8ab294aa8639 (diff) | |
download | fluxbox-3a8ec6512bee89ac495891665fc40bf1d893a389.zip fluxbox-3a8ec6512bee89ac495891665fc40bf1d893a389.tar.bz2 |
Fix a freed memory access in ~BScreen.
mit->second->parent() == 0 didn't do what it was supposed to. m_parent being
zero does not imply that no pointer points to it.
Signed-off-by: Tomas Janousek <tomi@nomi.cz>
-rw-r--r-- | src/Screen.cc | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index 400e7e2..16f39b1 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -559,21 +559,32 @@ BScreen::~BScreen() { | |||
559 | // we need to destroy it before we destroy workspaces | 559 | // we need to destroy it before we destroy workspaces |
560 | m_workspacemenu.reset(0); | 560 | m_workspacemenu.reset(0); |
561 | 561 | ||
562 | ExtraMenus::iterator mit = m_extramenus.begin(); | 562 | if (m_extramenus.size()) { |
563 | ExtraMenus::iterator mit_end = m_extramenus.end(); | 563 | // check whether extramenus are included in windowmenu |
564 | for (; mit != mit_end; ++mit) { | 564 | // if not, we clean them ourselves |
565 | // we set them to NOT internal so that they will be deleted when the | 565 | bool extramenus_in_windowmenu = false; |
566 | // menu is cleaned up. We can't delete them here because they are | 566 | for (size_t i = 0, n = m_windowmenu->numberOfItems(); i < n; i++) |
567 | // still in the menu | 567 | if (m_windowmenu->find(i)->submenu() == m_extramenus.begin()->second) { |
568 | // (They need to be internal for most of the time so that if we | 568 | extramenus_in_windowmenu = true; |
569 | // rebuild the menu, then they won't be removed. | 569 | break; |
570 | if (mit->second->parent() == 0) { | 570 | } |
571 | // not attached to our windowmenu | 571 | |
572 | // so we clean it up | 572 | ExtraMenus::iterator mit = m_extramenus.begin(); |
573 | delete mit->second; | 573 | ExtraMenus::iterator mit_end = m_extramenus.end(); |
574 | } else { | 574 | for (; mit != mit_end; ++mit) { |
575 | // let the parent clean it up | 575 | // we set them to NOT internal so that they will be deleted when the |
576 | mit->second->setInternalMenu(false); | 576 | // menu is cleaned up. We can't delete them here because they are |
577 | // still in the menu | ||
578 | // (They need to be internal for most of the time so that if we | ||
579 | // rebuild the menu, then they won't be removed. | ||
580 | if (! extramenus_in_windowmenu) { | ||
581 | // not attached to our windowmenu | ||
582 | // so we clean it up | ||
583 | delete mit->second; | ||
584 | } else { | ||
585 | // let the parent clean it up | ||
586 | mit->second->setInternalMenu(false); | ||
587 | } | ||
577 | } | 588 | } |
578 | } | 589 | } |
579 | 590 | ||