Skip to content

Commit e732dd7

Browse files
committed
Fix of free() error.
1 parent 6a0379d commit e732dd7

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

errors/2

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Start Undo
2+
Start Undo
3+
Start Undo
4+
Start Undo
5+
Save
6+
Save
7+
8+
=================================================================
9+
==15078==ERROR: LeakSanitizer: detected memory leaks
10+
11+
Direct leak of 109 byte(s) in 2 object(s) allocated from:
12+
#0 0x78c2f0ab4c38 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
13+
#1 0x78c2f15076cc in _nc_doalloc (/lib/x86_64-linux-gnu/libtinfo.so.6+0x106cc)
14+
15+
Direct leak of 24 byte(s) in 1 object(s) allocated from:
16+
#0 0x78c2f0ab4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
17+
#1 0x78c2f031ffa4 in __GI___tsearch misc/tsearch.c:337
18+
19+
SUMMARY: AddressSanitizer: 133 byte(s) leaked in 3 allocation(s).

include/text-editor/editorWindow.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ struct EditorWindow : TWindow{
1818
public:
1919
time_t open_time;
2020
private:
21-
EditorView view;
21+
EditorView& view;
2222
Editor editor; //potentially multiple editors in the future
2323
};

source/text-editor/editorWindow.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include <text-editor/editorWindow.hpp>
22

33
EditorWindow::EditorWindow(const TRect& bounds, TStringView aTitle, short aNumber) noexcept
4-
: TWindowInit(&EditorWindow::initFrame), TWindow(bounds, aTitle, aNumber), view(viewBounds(bounds)){
4+
: TWindowInit(&EditorWindow::initFrame), TWindow(bounds, aTitle, aNumber),
5+
view(*(new EditorView(viewBounds(bounds))))
6+
{
57
insert(&view);
68
view.attachEditor(&editor);
79
editor.openFile(aTitle);

0 commit comments

Comments
 (0)