]> git.proxmox.com Git - qemu.git/commitdiff
tests/test-mmap.c: Check mmap() return value before using it
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 14 Apr 2011 13:11:56 +0000 (14:11 +0100)
committerEdgar E. Iglesias <edgar.iglesias@gmail.com>
Thu, 14 Apr 2011 15:31:47 +0000 (17:31 +0200)
Correct the position of a "stop if MAP_FAILED" check in the mmap()
tests, so that if mmap() does fail we print a failure message
rather than segfaulting inside memcpy().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
tests/test-mmap.c

index fcb365f40ccd75255b465532c061b8480c8ea841..c578e2572acb6c00ea7c4bbc653d7d5bc9b4e7d0 100644 (file)
@@ -164,6 +164,7 @@ void check_aligned_anonymous_unfixed_colliding_mmaps(void)
                nlen = pagesize * 8;
                p3 = mmap(NULL, nlen, PROT_READ, 
                          MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+               fail_unless (p3 != MAP_FAILED);
 
                /* Check if the mmaped areas collide.  */
                if (p3 < p2 
@@ -174,7 +175,6 @@ void check_aligned_anonymous_unfixed_colliding_mmaps(void)
 
                /* Make sure we get pages aligned with the pagesize. The
                   target expects this.  */
-               fail_unless (p3 != MAP_FAILED);
                p = (uintptr_t) p3;
                fail_unless ((p & pagemask) == 0);
                munmap (p2, pagesize);