From 6d38164014cbea8f5e72be2ee33544634bf87e5e Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Fri, 26 Feb 1993 20:46:59 +0000 Subject: [PATCH] In krb5_copy_addresses(), do the right thing if the passed address is NULL. Lint cleanup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2507 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/copy_addrs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/krb5/krb/copy_addrs.c b/src/lib/krb5/krb/copy_addrs.c index 3f85522b4..6d5e3e37a 100644 --- a/src/lib/krb5/krb/copy_addrs.c +++ b/src/lib/krb5/krb/copy_addrs.c @@ -65,6 +65,11 @@ krb5_address ***outaddr; krb5_address ** tempaddr; register int nelems = 0; + if (!inaddr) { + *outaddr = 0; + return 0; + } + while (inaddr[nelems]) nelems++; /* one more for a null terminated list */ @@ -106,7 +111,7 @@ krb5_address ***outaddr; while (inaddr[nelems]) nelems++; while (tempaddr2[norigelems]) norigelems++; - tempaddr = realloc((char *)*outaddr, + tempaddr = (krb5_address **) realloc((char *)*outaddr, (nelems + norigelems + 1) * sizeof(*tempaddr)); if (!tempaddr) return ENOMEM; @@ -130,7 +135,8 @@ krb5_address ***outaddr; krb5_free_address(tempaddr[norigelems + nelems]); /* Try to allocate a smaller amount of memory for *outaddr. */ - tempaddr = realloc((char *)tempaddr, (norigelems + 1) * sizeof(*tempaddr)); + tempaddr = (krb5_address **) realloc((char *)tempaddr, + (norigelems + 1) * sizeof(*tempaddr)); if (tempaddr) *outaddr = tempaddr; return retval; -- 2.26.2