From e7924ebd519af78d4df0ca082800c4690f196111 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sat, 25 Aug 2018 18:27:37 +0800 Subject: [PATCH] fix bug of free null pointer --- src/font/bitmapfont.c | 2 +- src/newgdi/gdi.c | 3 ++- src/newgdi/icon.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/font/bitmapfont.c b/src/font/bitmapfont.c index 57bf722b..a2e26862 100644 --- a/src/font/bitmapfont.c +++ b/src/font/bitmapfont.c @@ -397,7 +397,7 @@ build_bmpfont_info (const char *bmpfont_name, const BITMAP* glyph_bmp, return NULL; /* set name */ - strncpy (bmpfont_info->name , bmpfont_name, LEN_UNIDEVFONT_NAME); + strncpy (bmpfont_info->name, bmpfont_name, LEN_UNIDEVFONT_NAME); bmpfont_info->name [LEN_UNIDEVFONT_NAME] = '\0'; /* set height */ diff --git a/src/newgdi/gdi.c b/src/newgdi/gdi.c index ac05b7fa..105863e2 100644 --- a/src/newgdi/gdi.c +++ b/src/newgdi/gdi.c @@ -3556,7 +3556,8 @@ static void destroy_dc_state (DCSTATE* dc_state, BOOL empty_crgn) { if (empty_crgn) EmptyClipRgn (&dc_state->lcrgn); - free (dc_state->pal.colors); + if (dc_state->pal.colors) + free (dc_state->pal.colors); free (dc_state); } diff --git a/src/newgdi/icon.c b/src/newgdi/icon.c index e0852d00..2adfaf7a 100644 --- a/src/newgdi/icon.c +++ b/src/newgdi/icon.c @@ -311,7 +311,8 @@ HICON GUIAPI LoadIconFromMem (HDC hdc, const void* area, int which) imagew = MGUI_ReadLE32Mem (&p); imageh = MGUI_ReadLE32Mem (&p); #else - p += sizeof(DWORD32); + p += sizeof(DWORD32); + p += sizeof(DWORD32); #endif /* check the biPlanes member; */ wTemp = MGUI_ReadLE16Mem (&p);