On Wed, Nov 6, 2024 at 10:42 AM Dehan Meng <dem...@redhat.com> wrote:

> It's now only freed at the end of the function.
>
> Signed-off-by: Dehan Meng <dem...@redhat.com>
> ---
>  qga/commands-linux.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/qga/commands-linux.c b/qga/commands-linux.c
> index 55c35bfc8f..70020621bf 100644
> --- a/qga/commands-linux.c
> +++ b/qga/commands-linux.c
> @@ -2138,8 +2138,7 @@ GuestNetworkRouteList
> *qmp_guest_network_get_route(Error **errp)
>          is_ipv6 = (i == 1);
>          fp = fopen(routeFiles[i], "r");
>          if (fp == NULL) {
> -            error_setg_errno(errp, errno, "open(\"%s\")", routeFiles[i]);
> -            free(line);
> +            error_setg_errno(errp, errno, "open(\"%s\")", route_files[i]);
>

Compilation failed

../qga/commands-linux.c:2140:59: error: ‘route_files’ undeclared (first use
in this function); did you mean ‘routeFiles’?
 2140 |             error_setg_errno(errp, errno, "open(\"%s\")",
route_files[i]);



>              continue;
>          }
>
> @@ -2148,7 +2147,6 @@ GuestNetworkRouteList
> *qmp_guest_network_get_route(Error **errp)
>                  firstLine = 0;
>                  continue;
>              }
> -
>              if (is_ipv6) {
>                  char destination[33], source[33], next_hop[33];
>                  int des_prefixlen, src_prefixlen, metric, refcnt, use,
> flags;
> @@ -2215,9 +2213,8 @@ GuestNetworkRouteList
> *qmp_guest_network_get_route(Error **errp)
>              QAPI_LIST_APPEND(tail, route);
>          }
>
> -        free(line);
>          fclose(fp);
>      }
> -
> +    free(line);
>      return head;
>  }
> --
> 2.40.1
>
>

Reply via email to