From 5ab1c032e6eea810142eb918c57222464482756f Mon Sep 17 00:00:00 2001 From: Dehan Meng Date: Thu, 7 Nov 2024 12:21:55 +0200 Subject: [PATCH] qemu-ga: Avoiding freeing line prematurely MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's now only freed at the end of the function. Signed-off-by: Dehan Meng Reviewed-by: Daniel P. Berrangé Reviewed-by: Konstantin Kostiuk Message-ID: <20241107102155.57573-4-kkostiuk@redhat.com> Signed-off-by: Konstantin Kostiuk --- qga/commands-linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qga/commands-linux.c b/qga/commands-linux.c index b0704ad423..cf077eb03d 100644 --- a/qga/commands-linux.c +++ b/qga/commands-linux.c @@ -2138,7 +2138,6 @@ GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp) fp = fopen(route_files[i], "r"); if (fp == NULL) { error_setg_errno(errp, errno, "open(\"%s\")", route_files[i]); - free(line); continue; } @@ -2212,9 +2211,9 @@ GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp) route = NULL; } - free(line); fclose(fp); } + free(line); return head; }