summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTobias Mueller <muelli@cryptobitch.de>2020-06-10 21:58:13 +0200
committerTobias Mueller <muelli@cryptobitch.de>2020-06-10 22:05:48 +0200
commita82e78f2e815b6cc248b227ef5e00b294c81499e (patch)
tree7c9746369e1f77312bb31b533467a03ae6edfd5c /tests
parentae582413f6ec587be0fe65fe77e975f7dbde0ef9 (diff)
downloadgdk-pixbuf-a82e78f2e815b6cc248b227ef5e00b294c81499e.tar.gz
tests: check for mmap failure
mmap does not return NULL on failure, but rather MAP_FAILED. https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/issues/158
Diffstat (limited to 'tests')
-rw-r--r--tests/pixbuf-readonly-to-mutable.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/pixbuf-readonly-to-mutable.c b/tests/pixbuf-readonly-to-mutable.c
index 7b88458cd..ea8a22f3f 100644
--- a/tests/pixbuf-readonly-to-mutable.c
+++ b/tests/pixbuf-readonly-to-mutable.c
@@ -19,6 +19,7 @@
#include "gdk-pixbuf/gdk-pixbuf.h"
#include "test-common.h"
+#include <errno.h>
#include <string.h>
#ifdef G_OS_UNIX
@@ -60,6 +61,7 @@ get_readonly_pixbuf (void)
#ifdef G_OS_UNIX
{
MappedBuf *buf;
+ int saved_errno;
int pagesize;
int pages;
int r;
@@ -76,8 +78,11 @@ get_readonly_pixbuf (void)
buf->len = pages * pagesize;
zero_fd = open("/dev/zero", O_RDWR);
g_assert(zero_fd != -1);
+ saved_errno = errno;
+ errno = 0;
buf->buf = mmap (NULL, buf->len, PROT_READ | PROT_WRITE, MAP_PRIVATE, zero_fd, 0);
- g_assert (buf->buf != NULL);
+ g_assert_true (errno >= 0);
+ errno = saved_errno;
close(zero_fd);
memcpy (buf->buf, gdk_pixbuf_get_pixels (reference), pixlen);