From: Theodore Tso Date: Fri, 26 Feb 1993 20:46:59 +0000 (+0000) Subject: In krb5_copy_addresses(), do the right thing if the passed address is NULL. X-Git-Tag: krb5-1.0-beta3~322 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6d38164014cbea8f5e72be2ee33544634bf87e5e;p=krb5.git 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 --- 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;