Skip to content

Commit

Permalink
util/oslib-win32: Fix check of filename, wfilename
Browse files Browse the repository at this point in the history
  • Loading branch information
mborgerson committed Dec 30, 2024
1 parent a1342ee commit 530a7b6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion block/file-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand All @@ -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();

Expand Down

0 comments on commit 530a7b6

Please sign in to comment.