From 530a7b65151e4d7e4010545987ee1e69abff53f0 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Sun, 29 Dec 2024 17:28:30 -0700 Subject: [PATCH] util/oslib-win32: Fix check of filename, wfilename --- block/file-win32.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/file-win32.c b/block/file-win32.c index b69de11096..5f3249693a 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -379,6 +379,10 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, } filename = qemu_opt_get(opts, "filename"); + if (filename == NULL) { + ret = -EINVAL; + goto fail; + } use_aio = get_aio_option(opts, flags, &local_err); if (local_err) { @@ -401,7 +405,8 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, } wfilename = g_utf8_to_utf16(filename, -1, NULL, NULL, NULL); - if (!filename) { + if (!wfilename) { + ret = -EINVAL; goto fail; } @@ -420,6 +425,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, OPEN_EXISTING, overlapped, NULL); #endif g_free(wfilename); + if (s->hfile == INVALID_HANDLE_VALUE) { int err = GetLastError();