Handle returned NULLs properly to: - avoid crashes in serialization. - properly report errors to the caller
Signed-off-by: Tomáš Golembiovský <tgole...@redhat.com> --- qga/commands-win32.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 9c959122d9..49fc747298 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -735,6 +735,12 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp) } fs->type = g_strdup(fs_name); fs->disk = build_guest_disk_info(guid, errp); + if (fs->disk == NULL) { + g_free(fs); + fs = NULL; + goto free; + } + free: g_free(mnt_point); return fs; @@ -755,7 +761,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp) do { GuestFilesystemInfo *info = build_guest_fsinfo(guid, errp); if (info == NULL) { - continue; + goto out; } new = g_malloc(sizeof(*ret)); new->value = info; @@ -767,6 +773,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp) error_setg_win32(errp, GetLastError(), "failed to find next volume"); } +out: FindVolumeClose(vol_h); return ret; } -- 2.19.0