[haiku-commits] haiku: hrev53642 - src/apps/terminal

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 21 Dec 2019 11:49:49 -0500 (EST)

hrev53642 adds 1 changeset to branch 'master'
old head: eeb89ccd8b759b7be71cd5b86175f8f8b014b6ec
new head: a02f7c7baec10508f955e604849f240e3d5288a8
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=a02f7c7baec1+%5Eeeb89ccd8b75

----------------------------------------------------------------------------

a02f7c7baec1: Terminal: Fix double-freed memory
  
  The base problem was, that every time I opened KeyMap while a Terminal
  was opened too, it eventually crashed. I followed along the trace and
  found that the code first frees the keymap and keymapchars in the
  _UpdateKeymap() and then calls SetKeymap for every tab opened which
  also tries to free the old keymap and keymapchars.
  
  TermWindow's _UpdateKeymap() method first frees the old keymap and 
keymapchars:
  
  delete fKeymap;
  delete[] fKeymapChars;
  
  and then calls SetKeyMap for every tab which tries to free the old keymap and 
keymapchars again:
  
  for (int32 i = 0; i < fTabView->CountTabs(); i++) {
        TermView* view = _TermViewAt(i);
        view->SetKeymap(fKeymap, fKeymapChars);
  }
  
  So TermView simply is not responsible for the memory, it merily has a pointer.
  
  Fixes #15502.
  
  Change-Id: Id08c863d811fbb72cce9be4c8fff2d3eb5f0064f
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2037
  Reviewed-by: Stephan Aßmus <superstippi@xxxxxx>

                             [ Zotyamester <szatmary.zoltan1222@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53642
Commit:      a02f7c7baec10508f955e604849f240e3d5288a8
URL:         https://git.haiku-os.org/haiku/commit/?id=a02f7c7baec1
Author:      Zotyamester <szatmary.zoltan1222@xxxxxxxxx>
Date:        Tue Dec 17 21:58:38 2019 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Sat Dec 21 16:49:45 2019 UTC

Ticket:      https://dev.haiku-os.org/ticket/15502

----------------------------------------------------------------------------

1 file changed, 3 deletions(-)
src/apps/terminal/TermView.cpp | 3 ---

----------------------------------------------------------------------------

diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp
index fd604be7ae..3c2232f880 100644
--- a/src/apps/terminal/TermView.cpp
+++ b/src/apps/terminal/TermView.cpp
@@ -732,9 +732,6 @@ TermView::SetEncoding(int encoding)
 void
 TermView::SetKeymap(const key_map* keymap, const char* chars)
 {
-       delete fKeymap;
-       delete[] fKeymapChars;
-
        fKeymap = keymap;
        fKeymapChars = chars;
 


Other related posts:

  • » [haiku-commits] haiku: hrev53642 - src/apps/terminal - Adrien Destugues