From 81a846f32f3f5cbb445168a2d4da55576bd4a1bc Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Thu, 14 Jun 2012 21:03:31 +0800 Subject: [PATCH] properly free and unmap memory in closeFrameBuffer --- einkfb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/einkfb.c b/einkfb.c index a4b995e71..13ec24596 100644 --- a/einkfb.c +++ b/einkfb.c @@ -140,13 +140,15 @@ static int closeFrameBuffer(lua_State *L) { // should be save if called twice if(fb->buf != NULL && fb->buf->data != NULL) { #ifndef EMULATE_READER - munmap(fb->buf->data, fb->finfo.smem_len); + if (fb->vinfo.bits_per_pixel != 4) { + munmap(fb->read_buf->data, fb->finfo.smem_len); + free(fb->buf->data); + } else { + munmap(fb->buf->data, fb->finfo.smem_len); + } close(fb->fd); #else free(fb->buf->data); - if (fb->vinfo.bits_per_pixel != 4) { - free(fb->real_buf->data); - } #endif fb->buf->data = NULL; // the blitbuffer in fb->buf should be freed