Valgrind shows that the memory allocated for ee.e_hostname in
getexportent() is being leaked. While there _is_ a call to xfree(), by
the time it gets called the leak's already happened. Moving the xfree()
call so that it occurs before the assignment that overwrites ee fixes
this.
Signed-off-by: Scott Mayhew <[email protected]>
---
support/nfs/exports.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/support/nfs/exports.c b/support/nfs/exports.c
index eb782b9..4b17d3c 100644
--- a/support/nfs/exports.c
+++ b/support/nfs/exports.c
@@ -154,6 +154,7 @@ getexportent(int fromkernel, int fromexports)
}
}
+ xfree(ee.e_hostname);
ee = def_ee;
/* Check for default client */
@@ -176,7 +177,6 @@ getexportent(int fromkernel, int fromexports)
if (!has_default_opts)
xlog(L_WARNING, "No options for %s %s: suggest %s(sync) to avoid warning", ee.e_path, exp, exp);
}
- xfree(ee.e_hostname);
ee.e_hostname = xstrdup(hostname);
if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0)
--
1.9.3
On 02/20/2015 01:49 PM, Scott Mayhew wrote:
> Valgrind shows that the memory allocated for ee.e_hostname in
> getexportent() is being leaked. While there _is_ a call to xfree(), by
> the time it gets called the leak's already happened. Moving the xfree()
> call so that it occurs before the assignment that overwrites ee fixes
> this.
>
> Signed-off-by: Scott Mayhew <[email protected]>
Committed!
steved.
> ---
> support/nfs/exports.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/support/nfs/exports.c b/support/nfs/exports.c
> index eb782b9..4b17d3c 100644
> --- a/support/nfs/exports.c
> +++ b/support/nfs/exports.c
> @@ -154,6 +154,7 @@ getexportent(int fromkernel, int fromexports)
> }
> }
>
> + xfree(ee.e_hostname);
> ee = def_ee;
>
> /* Check for default client */
> @@ -176,7 +177,6 @@ getexportent(int fromkernel, int fromexports)
> if (!has_default_opts)
> xlog(L_WARNING, "No options for %s %s: suggest %s(sync) to avoid warning", ee.e_path, exp, exp);
> }
> - xfree(ee.e_hostname);
> ee.e_hostname = xstrdup(hostname);
>
> if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0)
>