[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] util/oslib-win32: Fix fatal assertion in qemu_try_memalign
From: |
Stefan Weil |
Subject: |
[PATCH] util/oslib-win32: Fix fatal assertion in qemu_try_memalign |
Date: |
Fri, 11 Jun 2021 12:58:46 +0200 |
The function is called with alignment == 0 which caused an assertion.
Use the code from oslib_posix.c to fix that regression (introduced
by commit ed6f53f9ca9).
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
util/oslib-win32.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index ca99356fdf..7b318ea835 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -57,7 +57,11 @@ void *qemu_try_memalign(size_t alignment, size_t size)
void *ptr;
g_assert(size != 0);
- g_assert(is_power_of_2(alignment));
+ if (alignment < sizeof(void *)) {
+ alignment = sizeof(void *);
+ } else {
+ g_assert(is_power_of_2(alignment));
+ }
ptr = _aligned_malloc(size, alignment);
trace_qemu_memalign(alignment, size, ptr);
return ptr;
--
2.30.2
- [PATCH] util/oslib-win32: Fix fatal assertion in qemu_try_memalign,
Stefan Weil <=