From d46323883c9d52eedc961c0978fac79c070400ed Mon Sep 17 00:00:00 2001 From: graindcafe Date: Mon, 27 Dec 2021 12:06:13 +0100 Subject: [PATCH] Properly check for mmap failure --- lib/quirc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/quirc.c b/lib/quirc.c index f1244fc..0cca93c 100644 --- a/lib/quirc.c +++ b/lib/quirc.c @@ -75,7 +75,7 @@ int quirc_resize(struct quirc *q, int w, int h) * mmap will ensure memory page alignment */ image = mmap(NULL, newdim, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (!image) + if (image == MAP_FAILED) goto fail; memset(image, 0, newdim); @@ -136,7 +136,7 @@ int quirc_resize(struct quirc *q, int w, int h) return 0; /* NOTREACHED */ fail: - if (image != NULL) + if (image != NULL && image != MAP_FAILED) munmap(image, newdim); free(pixels); free(vars);