* svr_principal.c (add_to_history): Don't call realloc() on a NULL
authorTom Yu <tlyu@mit.edu>
Sun, 9 Mar 1997 23:05:31 +0000 (23:05 +0000)
committerTom Yu <tlyu@mit.edu>
Sun, 9 Mar 1997 23:05:31 +0000 (23:05 +0000)
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
src/lib/kadm5/srv/svr_principal.c

index 6383ad45c68025954cff9bd79351f10acb6cd4e5..d462a0d773f168432001acfce6ccd87ad1d6abf6 100644 (file)
@@ -1,3 +1,8 @@
+Sun Mar  9 13:40:33 1997  Tom Yu  <tlyu@mit.edu>
+
+       * 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  <hartmans@tertius.mit.edu>
 
        * Makefile.in (SHLIB_EXPDEPS): s/.so/$(SHLIBEXT)
index f4a21f39aae2a1893035a59496c1ad0548c8b537..5ff1b4976d7791442a486ba3cb9a32b7ff0fe875 100644 (file)
@@ -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);