summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2010-10-12 10:56:26 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2010-12-17 17:01:52 -0500
commit7d7b03c0911584f687a7fd57a3f5d5eed21080e0 (patch)
treefd260f435d926f62975f3d48c2346476d786c069
parentd41522113ec84e74f7915599fd7624f842be8862 (diff)
Make the argument to fence_malloc() an int64_t
That way we can detect if someone attempts to allocate a negative size and abort instead of just returning NULL and segfaulting later.
-rw-r--r--test/utils.c7
-rw-r--r--test/utils.h2
2 files changed, 6 insertions, 3 deletions
diff --git a/test/utils.c b/test/utils.c
index cde9c62f..a7abec5d 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -232,7 +232,7 @@ typedef struct
#endif
void *
-fence_malloc (uint32_t len)
+fence_malloc (int64_t len)
{
unsigned long page_size = getpagesize();
unsigned long page_mask = page_size - 1;
@@ -246,12 +246,15 @@ fence_malloc (uint32_t len)
uint8_t *payload;
uint8_t *addr;
+ if (len < 0)
+ abort();
+
addr = mmap (NULL, n_bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
-1, 0);
if (addr == MAP_FAILED)
{
- printf ("mmap failed on %u %u\n", len, n_bytes);
+ printf ("mmap failed on %lld %u\n", (long long int)len, n_bytes);
return NULL;
}
diff --git a/test/utils.h b/test/utils.h
index 7b33461b..abd11ec1 100644
--- a/test/utils.h
+++ b/test/utils.h
@@ -57,7 +57,7 @@ image_endian_swap (pixman_image_t *img, int bpp);
* so that out-of-bounds access will cause segfaults
*/
void *
-fence_malloc (uint32_t len);
+fence_malloc (int64_t len);
void
fence_free (void *data);