From 210d6ad784d55362d24a22cd7e07725a794d46cd Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 5 Aug 2021 17:30:53 +0200 Subject: minor fixes and cleanups, and update to use new version of libgrapheme and add text length parameter instead of using NUL-termination MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libskrift_open_font_fd.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libskrift_open_font_fd.c') diff --git a/libskrift_open_font_fd.c b/libskrift_open_font_fd.c index c00422e..e134cd8 100644 --- a/libskrift_open_font_fd.c +++ b/libskrift_open_font_fd.c @@ -13,6 +13,7 @@ libskrift_open_font_fd(LIBSKRIFT_FONT **fontp, int fd) saved_errno = errno; if (fstat(fd, &st) < 0 || !st.st_size || !S_ISREG(st.st_mode)) { + fallback: for (;;) { if (off + 2048 > size) { size += 8192; @@ -39,6 +40,8 @@ libskrift_open_font_fd(LIBSKRIFT_FONT **fontp, int fd) errno = saved_errno; } else { mem = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (mem == MAP_FAILED || !mem) + goto fallback; size = (size_t)st.st_size; mmapped = 1; } -- cgit v1.2.3-70-g09d2