]> git.mdlowis.com Git - archive/afm.git/commitdiff
fix memory leak
authora bellenir <a@bellenir.com>
Sat, 26 Jul 2014 02:20:26 +0000 (02:20 +0000)
committera bellenir <a@bellenir.com>
Sat, 26 Jul 2014 02:20:26 +0000 (02:20 +0000)
source/screen.c

index 2402c44b1c3af845c71a8f8bec13a000134b566f..1c738f48d125d0cf7329a5fe77d843f63a99590a 100644 (file)
@@ -118,8 +118,10 @@ char* pwd(){
 static frame_t* screen_frame_new(void) {
     frame_t* p_frame = (frame_t*)mem_allocate(sizeof(frame_t),&screen_frame_free);
     p_frame->p_win = newwin(1, 1, 0, 0);
-    char* path = state_get_focused_frame() ? state_get_focused_frame()->workdir->path : pwd();
+    bool first_window = !state_get_focused_frame();
+    char* path = first_window ? pwd() : state_get_focused_frame()->workdir->path;
     p_frame->workdir = workdir_new(path);
+    if(first_window) mem_release(path);
     return p_frame;
 }