set free'd pointer to NULL

This commit is contained in:
devsaurus 2015-02-25 23:17:08 +01:00
parent 2cfb86b5b5
commit 7ae293d566
1 changed files with 7 additions and 4 deletions

View File

@ -1002,7 +1002,10 @@ static int lu8g_close_display( lua_State *L )
// free up allocated page buffer // free up allocated page buffer
if (lud->pb.buf != NULL) if (lud->pb.buf != NULL)
{
c_free( lud->pb.buf ); c_free( lud->pb.buf );
lud->pb.buf = NULL;
}
return 0; return 0;
} }
@ -1033,10 +1036,10 @@ static int lu8g_ssd1306_128x64_i2c( lua_State *L )
// populate and allocate page buffer // populate and allocate page buffer
// constants taken from u8g_dev_ssd1306_128x64.c: // constants taken from u8g_dev_ssd1306_128x64.c:
// PAGE_HEIGHT // PAGE_HEIGHT
// | Height // | Height
// | | WIDTH // | | WIDTH
// | | | // | | |
lud->pb = (u8g_pb_t){ { 8, 64, 0, 0, 0 }, 128, NULL }; lud->pb = (u8g_pb_t){ { 8, 64, 0, 0, 0 }, 128, NULL };
// //
if ((lud->pb.buf = (void *)c_zalloc(lud->pb.width)) == NULL) if ((lud->pb.buf = (void *)c_zalloc(lud->pb.width)) == NULL)