From f5fa22f5e8bca7eb2548669daf998aa34d9fdc84 Mon Sep 17 00:00:00 2001 From: Mark Eichin Date: Sat, 24 Feb 1996 00:31:42 +0000 Subject: [PATCH] Sat Feb 3 22:37:55 1996 Mark Eichin * network.c (add_port): sunos realloc doesn't handle a NULL pointer, so protect with a macro. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7508 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kdc/ChangeLog | 5 +++++ src/kdc/network.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/kdc/ChangeLog b/src/kdc/ChangeLog index 6b62634e6..61be8fbd7 100644 --- a/src/kdc/ChangeLog +++ b/src/kdc/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 3 22:37:55 1996 Mark Eichin + + * network.c (add_port): sunos realloc doesn't handle a NULL + pointer, so protect with a macro. + Sat Feb 10 02:46:27 1996 Mark Eichin * main.c (initialize_realms): look for [kdc] profile=path for diff --git a/src/kdc/network.c b/src/kdc/network.c index 7f27ee58b..e098761bd 100644 --- a/src/kdc/network.c +++ b/src/kdc/network.c @@ -49,6 +49,8 @@ static int max_udp_ports = 0; static fd_set select_fds; static int select_nfds; +#define safe_realloc(p,n) ((p)?(realloc(p,n)):(malloc(n))) + static krb5_error_code add_port(port) u_short port; { @@ -64,12 +66,12 @@ static krb5_error_code add_port(port) if (n_udp_ports >= max_udp_ports) { new_max = max_udp_ports + 10; - new_fds = realloc(udp_port_fds, new_max * sizeof(int)); + new_fds = safe_realloc(udp_port_fds, new_max * sizeof(int)); if (new_fds == 0) return ENOMEM; udp_port_fds = new_fds; - new_ports = realloc(udp_port_nums, new_max * sizeof(u_short)); + new_ports = safe_realloc(udp_port_nums, new_max * sizeof(u_short)); if (new_ports == 0) return ENOMEM; udp_port_nums = new_ports; @@ -80,7 +82,7 @@ static krb5_error_code add_port(port) udp_port_nums[n_udp_ports++] = port; return 0; } - +#undef safe_realloc krb5_error_code setup_network(prog) -- 2.26.2