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>
diff --git a/qga/commands-linux.c b/qga/commands-linux.c
index b0704ad..cf077eb 100644
--- a/qga/commands-linux.c
+++ b/qga/commands-linux.c
@@ -2138,7 +2138,6 @@
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 @@
route = NULL;
}
- free(line);
fclose(fp);
}
+ free(line);
return head;
}