From: a bellenir Date: Sat, 26 Jul 2014 02:20:26 +0000 (+0000) Subject: fix memory leak X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=c22771b1f9ecac611eb7611e67df3b4c8e428839;p=archive%2Fafm.git fix memory leak --- diff --git a/source/screen.c b/source/screen.c index 2402c44..1c738f4 100644 --- a/source/screen.c +++ b/source/screen.c @@ -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; }