aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/oslib-posix.c3
-rw-r--r--util/oslib-win32.c4
2 files changed, 6 insertions, 1 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 0278902ee7..f7e22f4ff9 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -209,6 +209,9 @@ void *qemu_try_memalign(size_t alignment, size_t size)
g_assert(is_power_of_2(alignment));
}
+ if (size == 0) {
+ size++;
+ }
#if defined(CONFIG_POSIX_MEMALIGN)
int ret;
ret = posix_memalign(&ptr, alignment, size);
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 0585741469..8c28d70904 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -48,12 +48,14 @@ void *qemu_try_memalign(size_t alignment, size_t size)
{
void *ptr;
- g_assert(size != 0);
if (alignment < sizeof(void *)) {
alignment = sizeof(void *);
} else {
g_assert(is_power_of_2(alignment));
}
+ if (size == 0) {
+ size++;
+ }
ptr = _aligned_malloc(size, alignment);
trace_qemu_memalign(alignment, size, ptr);
return ptr;