diff --git a/graphics/nxmu/nxmu_mouse.c b/graphics/nxmu/nxmu_mouse.c index 66a6cfb8d14..de57aa556ca 100644 --- a/graphics/nxmu/nxmu_mouse.c +++ b/graphics/nxmu/nxmu_mouse.c @@ -58,6 +58,39 @@ static struct nxgl_point_s g_mrange; static uint8_t g_mbutton; static struct nxbe_window_s *g_mwnd; +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxmu_revalidate_g_mwnd + * + * Description: + * Check if the window pointed to by g_mwnd still exists. If it does, + * this function returns a pointer to it. Otherwise returns NULL. + * + ****************************************************************************/ + +static struct nxbe_window_s *nxmu_revalidate_g_mwnd(struct nxbe_window_s *wnd) +{ + if (!g_mwnd) + { + return NULL; + } + + while (wnd) + { + if (wnd == g_mwnd) + { + return wnd; + } + + wnd = wnd->below; + } + + return NULL; +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -178,15 +211,24 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe, * started in. */ - if (oldbuttons && g_mwnd && g_mwnd->cb->mousein) + if (oldbuttons) { - struct nxclimsg_mousein_s outmsg; - outmsg.msgid = NX_CLIMSG_MOUSEIN; - outmsg.wnd = g_mwnd; - outmsg.buttons = g_mbutton; - nxgl_vectsubtract(&outmsg.pos, &g_mpos, &g_mwnd->bounds.pt1); + g_mwnd = nxmu_revalidate_g_mwnd(fe->be.topwnd); + if (g_mwnd && g_mwnd->cb->mousein) + { + struct nxclimsg_mousein_s outmsg; + outmsg.msgid = NX_CLIMSG_MOUSEIN; + outmsg.wnd = g_mwnd; + outmsg.buttons = g_mbutton; + nxgl_vectsubtract(&outmsg.pos, &g_mpos, &g_mwnd->bounds.pt1); - return nxmu_sendclientwindow(g_mwnd, &outmsg, sizeof(struct nxclimsg_mousein_s)); + return nxmu_sendclientwindow(g_mwnd, &outmsg, sizeof(struct nxclimsg_mousein_s)); + } + else + { + /* Ignore events until the button is released */ + return OK; + } } /* Pick the window to receive the mouse event. Start with the top diff --git a/libs/libc/string/lib_strerror.c b/libs/libc/string/lib_strerror.c index 5b0244d4621..28e8d1f12e0 100644 --- a/libs/libc/string/lib_strerror.c +++ b/libs/libc/string/lib_strerror.c @@ -76,6 +76,7 @@ struct errno_strmap_s static const struct errno_strmap_s g_errnomap[] = { + { 0, "Success" }, { EPERM, EPERM_STR }, { ENOENT, ENOENT_STR }, { ESRCH, ESRCH_STR }, @@ -208,6 +209,7 @@ static const struct errno_strmap_s g_errnomap[] = static const struct errno_strmap_s g_errnomap[] = { + { 0, "OK" }, { EPERM, "EPERM" }, { ENOENT, "ENOENT" }, { ESRCH, "ESRCH" }, diff --git a/libs/libc/string/lib_strrchr.c b/libs/libc/string/lib_strrchr.c index 0833e047464..048b80a3a50 100644 --- a/libs/libc/string/lib_strrchr.c +++ b/libs/libc/string/lib_strrchr.c @@ -53,7 +53,7 @@ FAR char *strrchr(FAR const char *s, int c) { if (s) { - const char *p = &s[strlen(s) - 1]; + const char *p = &s[strlen(s)]; for (; p >= s; p--) { if (*p == c) diff --git a/libs/libnx/nxfonts/nxfonts_getfont.c b/libs/libnx/nxfonts/nxfonts_getfont.c index 30ed22dead1..2b2b8dd4838 100644 --- a/libs/libnx/nxfonts/nxfonts_getfont.c +++ b/libs/libnx/nxfonts/nxfonts_getfont.c @@ -495,7 +495,7 @@ static inline FAR const struct nx_fontset_s * * font. */ - if (ch != ' ') + if (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r') { gwarn("WARNING: No bitmap for code %02x\n", ch); } diff --git a/libs/libnx/nxfonts/nxfonts_sans17x22.h b/libs/libnx/nxfonts/nxfonts_sans17x22.h index 7649d112528..1112444c63d 100644 --- a/libs/libnx/nxfonts/nxfonts_sans17x22.h +++ b/libs/libnx/nxfonts/nxfonts_sans17x22.h @@ -226,7 +226,7 @@ #define NXFONT_BITMAP_72 {0x81, 0x81, 0x81, 0x81, 0x81, 0xff, 0x81, 0x81, 0x81, 0x81, 0x81} /* I (73) */ -#define NXFONT_METRICS_73 {1, 1, 11, 2, 6, 0} +#define NXFONT_METRICS_73 {1, 2, 11, 2, 6, 0} #define NXFONT_BITMAP_73 {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80} /* J (74) */ diff --git a/libs/libnx/nxtk/nxtk_bitmapwindow.c b/libs/libnx/nxtk/nxtk_bitmapwindow.c index 40026958ea6..d7f889cbaa1 100644 --- a/libs/libnx/nxtk/nxtk_bitmapwindow.c +++ b/libs/libnx/nxtk/nxtk_bitmapwindow.c @@ -117,6 +117,12 @@ int nxtk_bitmapwindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *dest, nxtk_subwindowclip(fwnd, &clipdest, dest, &fwnd->fwrect); + /* Just return if completely outside screen */ + if (nxgl_nullrect(&clipdest)) + { + return OK; + } + /* Now, move the bitmap origin so that it is relative to the containing * window, not the sub-window. * diff --git a/mm/Kconfig b/mm/Kconfig index 76fa2beb684..aa3dc2df584 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -148,4 +148,11 @@ config MM_SHM Build in support for the shared memory interfaces shmget(), shmat(), shmctl(), and shmdt(). +config MM_FILL_ALLOCATIONS + bool "Fill allocations with debug value" + default n + ---help--- + Fill all malloc() allocations with 0xAA. This helps + detecting uninitialized variable errors. + source "mm/iob/Kconfig" diff --git a/mm/mm_heap/mm_free.c b/mm/mm_heap/mm_free.c index 4dad12e3666..95413f2bd9b 100644 --- a/mm/mm_heap/mm_free.c +++ b/mm/mm_heap/mm_free.c @@ -81,11 +81,17 @@ void mm_free(FAR struct mm_heap_s *heap, FAR void *mem) /* Map the memory chunk into a free node */ node = (FAR struct mm_freenode_s *)((FAR char *)mem - SIZEOF_MM_ALLOCNODE); + + /* Sanity check against double-frees */ + + DEBUGASSERT(node->preceding & MM_ALLOC_BIT); + node->preceding &= ~MM_ALLOC_BIT; /* Check if the following node is free and, if so, merge it */ next = (FAR struct mm_freenode_s *)((FAR char *)node + node->size); + DEBUGASSERT((next->preceding & ~MM_ALLOC_BIT) == node->size); if ((next->preceding & MM_ALLOC_BIT) == 0) { FAR struct mm_allocnode_s *andbeyond; @@ -120,6 +126,7 @@ void mm_free(FAR struct mm_heap_s *heap, FAR void *mem) */ prev = (FAR struct mm_freenode_s *)((FAR char *)node - node->preceding); + DEBUGASSERT((node->preceding & ~MM_ALLOC_BIT) == prev->size); if ((prev->preceding & MM_ALLOC_BIT) == 0) { /* Remove the node. There must be a predecessor, but there may diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c index cf72dc99318..ef3630626a4 100644 --- a/mm/mm_heap/mm_malloc.c +++ b/mm/mm_heap/mm_malloc.c @@ -42,6 +42,7 @@ #include #include +#include #include @@ -184,6 +185,13 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) mm_givesemaphore(heap); +#ifdef CONFIG_MM_FILL_ALLOCATIONS + if (ret) + { + memset(ret, 0xAA, alignsize - SIZEOF_MM_ALLOCNODE); + } +#endif + /* If CONFIG_DEBUG_MM is defined, then output the result of the allocation * to the SYSLOG. */