From 1b2421185ee575bc224985506c735ab483711433 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Sun, 9 Mar 1997 23:05:31 +0000 Subject: [PATCH] * svr_principal.c (add_to_history): Don't call realloc() on a NULL pointer, lest non-ANSI compliant systems like SunOS fail. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9998 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/kadm5/srv/ChangeLog | 5 +++++ src/lib/kadm5/srv/svr_principal.c | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lib/kadm5/srv/ChangeLog b/src/lib/kadm5/srv/ChangeLog index 6383ad45c..d462a0d77 100644 --- a/src/lib/kadm5/srv/ChangeLog +++ b/src/lib/kadm5/srv/ChangeLog @@ -1,3 +1,8 @@ +Sun Mar 9 13:40:33 1997 Tom Yu + + * svr_principal.c (add_to_history): Don't call realloc() on a NULL + pointer, lest non-ANSI compliant systems like SunOS fail. + Sat Feb 22 01:34:08 1997 Sam Hartman * Makefile.in (SHLIB_EXPDEPS): s/.so/$(SHLIBEXT) diff --git a/src/lib/kadm5/srv/svr_principal.c b/src/lib/kadm5/srv/svr_principal.c index f4a21f39a..5ff1b4976 100644 --- a/src/lib/kadm5/srv/svr_principal.c +++ b/src/lib/kadm5/srv/svr_principal.c @@ -964,9 +964,14 @@ static kadm5_ret_t add_to_history(krb5_context context, /* resize the adb->old_keys array if necessary */ if (adb->old_key_len < pol->pw_history_num-1) { - adb->old_keys = (osa_pw_hist_ent *) - realloc(adb->old_keys, - (adb->old_key_len+1)*sizeof(osa_pw_hist_ent)); + if (adb->old_keys == NULL) { + adb->old_keys = (osa_pw_hist_ent *) + malloc((adb->old_key_len + 1) * sizeof (osa_pw_hist_ent)); + } else { + adb->old_keys = (osa_pw_hist_ent *) + realloc(adb->old_keys, + (adb->old_key_len + 1) * sizeof (osa_pw_hist_ent)); + } if (adb->old_keys == NULL) return(ENOMEM); -- 2.26.2