qemu-ga: Avoiding freeing line prematurely

It's now only freed at the end of the function.

Signed-off-by: Dehan Meng <demeng@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Message-ID: <20241107102155.57573-4-kkostiuk@redhat.com>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
This commit is contained in:
Dehan Meng 2024-11-07 12:21:55 +02:00 committed by Konstantin Kostiuk
parent ccc2dfab57
commit 5ab1c032e6

View File

@ -2138,7 +2138,6 @@ GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp)
fp = fopen(route_files[i], "r"); fp = fopen(route_files[i], "r");
if (fp == NULL) { if (fp == NULL) {
error_setg_errno(errp, errno, "open(\"%s\")", route_files[i]); error_setg_errno(errp, errno, "open(\"%s\")", route_files[i]);
free(line);
continue; continue;
} }
@ -2212,9 +2211,9 @@ GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp)
route = NULL; route = NULL;
} }
free(line);
fclose(fp); fclose(fp);
} }
free(line);
return head; return head;
} }