This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit f38783f4b586922f1cbca95e4348b7dad5a79037 Author: Xu Xingliang <[email protected]> AuthorDate: Thu Dec 16 11:10:33 2021 +0800 libc/locale: check if mmap failed before proceeding. Signed-off-by: Xu Xingliang <[email protected]> --- libs/libc/locale/lib_gettext.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/libc/locale/lib_gettext.c b/libs/libc/locale/lib_gettext.c index cb16c2e..2882ba1 100644 --- a/libs/libc/locale/lib_gettext.c +++ b/libs/libc/locale/lib_gettext.c @@ -119,7 +119,8 @@ static FAR void *momap(FAR const char *path, FAR size_t *size) { *size = st.st_size; map = mmap(NULL, *size, PROT_READ, MAP_SHARED, fd, 0); - if (map[0] != MO_MAGIC && map[0] != __swap_uint32(MO_MAGIC)) + if (map != MAP_FAILED && + map[0] != MO_MAGIC && map[0] != __swap_uint32(MO_MAGIC)) { munmap(map, *size); map = MAP_FAILED;
