summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorStefan Weil2021-06-11 12:58:46 +0200
committerRichard Henderson2021-06-19 23:51:51 +0200
commit1c9638667b7068539dc5783c9428d588b14162ea (patch)
tree26b345d3596390b66adafbe4999451f5ab7eb3fe /util
parenttcg: expose TCGCond manipulation routines (diff)
downloadqemu-1c9638667b7068539dc5783c9428d588b14162ea.tar.gz
qemu-1c9638667b7068539dc5783c9428d588b14162ea.tar.xz
qemu-1c9638667b7068539dc5783c9428d588b14162ea.zip
util/oslib-win32: Fix fatal assertion in qemu_try_memalign
The function is called with alignment == 0 which caused an assertion. Use the code from oslib-posix.c to fix that regression. Fixes: ed6f53f9ca9 Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20210611105846.347954-1-sw@weilnetz.de> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'util')
-rw-r--r--util/oslib-win32.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index ee3a3692d8..af559ef339 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -58,7 +58,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;