diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2010-04-23 12:08:49 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2010-04-23 12:12:03 -0400 |
commit | aa4b66b12b631885ed85f3ebe97e68b033407178 (patch) | |
tree | a0b08cd5974f183aa439ec54a608a3dc50a3a192 /support | |
parent | 5d954d871fb265af584faef5df6e2e7e6ada7c3b (diff) | |
download | nfs-utils-aa4b66b12b631885ed85f3ebe97e68b033407178.tar.gz nfs-utils-aa4b66b12b631885ed85f3ebe97e68b033407178.tar.xz nfs-utils-aa4b66b12b631885ed85f3ebe97e68b033407178.zip |
libexport.a: Allow m_hostname allocation to fail instead of exit
Clean up: Replace xstrdup() with strdup(3) in client_init(), to
prevent the process from exiting if the memory allocation fails.
Note that both of client_init()'s callers set m_hostname equal to NULL
before calling, thus the extra free(3) at the top of client_init() is
unneeded.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'support')
-rw-r--r-- | support/export/client.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/support/export/client.c b/support/export/client.c index 8f83da3..20d662a 100644 --- a/support/export/client.c +++ b/support/export/client.c @@ -55,7 +55,7 @@ init_addrlist(nfs_client *clp, const struct hostent *hp) static void client_free(nfs_client *clp) { - xfree(clp->m_hostname); + free(clp->m_hostname); xfree(clp); } @@ -154,11 +154,9 @@ client_dup(nfs_client *clp, struct hostent *hp) static int client_init(nfs_client *clp, const char *hname, struct hostent *hp) { - xfree(clp->m_hostname); - if (hp) - clp->m_hostname = xstrdup(hp->h_name); - else - clp->m_hostname = xstrdup(hname); + clp->m_hostname = strdup(hname); + if (clp->m_hostname == NULL) + return 0; clp->m_exported = 0; clp->m_count = 0; |