aboutsummaryrefslogtreecommitdiff
path: root/nis/nis_clone_res.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /nis/nis_clone_res.c
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.bz2
2.5-18.1
Diffstat (limited to 'nis/nis_clone_res.c')
-rw-r--r--nis/nis_clone_res.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/nis/nis_clone_res.c b/nis/nis_clone_res.c
index 135f397..021f7cb 100644
--- a/nis/nis_clone_res.c
+++ b/nis/nis_clone_res.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -26,10 +26,9 @@
nis_result *
nis_clone_result (const nis_result *src, nis_result *dest)
{
- unsigned char *addr;
+ char *addr;
unsigned int size;
XDR xdrs;
- nis_result *res;
if (src == NULL)
return (NULL);
@@ -38,6 +37,16 @@ nis_clone_result (const nis_result *src, nis_result *dest)
if ((addr = calloc(1, size)) == NULL)
return NULL;
+ xdrmem_create (&xdrs, addr, size, XDR_ENCODE);
+ if (!_xdr_nis_result (&xdrs, (nis_result *)src))
+ {
+ xdr_destroy (&xdrs);
+ free (addr);
+ return NULL;
+ }
+ xdr_destroy (&xdrs);
+
+ nis_result *res;
if (dest == NULL)
{
if ((res = calloc (1, sizeof (nis_result))) == NULL)
@@ -49,18 +58,12 @@ nis_clone_result (const nis_result *src, nis_result *dest)
else
res = dest;
- xdrmem_create(&xdrs, addr, size, XDR_ENCODE);
- if (!_xdr_nis_result (&xdrs, (nis_result *)src))
- {
- xdr_destroy (&xdrs);
- free (addr);
- return NULL;
- }
- xdr_destroy (&xdrs);
- xdrmem_create(&xdrs, addr, size, XDR_DECODE);
- if (!_xdr_nis_result(&xdrs, res))
+ xdrmem_create (&xdrs, addr, size, XDR_DECODE);
+ if (!_xdr_nis_result (&xdrs, res))
{
xdr_destroy (&xdrs);
+ if (res != dest)
+ free (res);
free (addr);
return NULL;
}