realm_tcp_ports data, kdc_realmlist, close the replay cache, and
free the lookaside cache.
* network.c (FREE_SET_DATA): Do not free a NULL pointer.
* replay.c, kdc_util.h: Add kdc_free_lookaside() to clear the lookaside
cache on shutdown - to search for memory leaks.
* rtest.c (main): Do not allocate or free a NULL pointer.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15080
dc483132-0cff-0310-8789-
dd5450dbe970
+2003-01-03 Ezra Peisach <epeisach@bu.edu>
+
+ * main.c: On exit, free more allocated memory, including:
+ realm_tcp_ports data, kdc_realmlist, close the replay cache, and
+ free the lookaside cache.
+
+ * network.c (FREE_SET_DATA): Do not free a NULL pointer.
+
+ * replay.c, kdc_util.h: Add kdc_free_lookaside() to clear the lookaside
+ cache on shutdown - to search for memory leaks.
+
+ * rtest.c (main): Do not allocate or free a NULL pointer.
+
2002-12-30 Ken Raeburn <raeburn@mit.edu>
* kerberos_v4.c (process_v4): Use a temporary variable for the
krb5_data **);
void kdc_insert_lookaside (krb5_data *, const krb5_fulladdr *,
krb5_data *);
+void kdc_free_lookaside(void);
/* sock2p.c */
extern void sockaddr2p (const struct sockaddr *, char *, size_t, int *);
free(rdp->realm_stash);
if (rdp->realm_ports)
free(rdp->realm_ports);
+ if (rdp->realm_tcp_ports)
+ free(rdp->realm_tcp_ports);
if (rdp->realm_kstypes)
free(rdp->realm_kstypes);
if (rdp->realm_keytab)
krb5_free_context(rdp->realm_context);
}
memset((char *) rdp, 0, sizeof(*rdp));
+ free(rdp);
}
/*
{
int i;
- for (i = 0; i < kdc_numrealms; i++)
+ for (i = 0; i < kdc_numrealms; i++) {
finish_realm(kdc_realmlist[i]);
+ kdc_realmlist[i] = 0;
+ }
}
/*
krb5_klog_syslog(LOG_INFO, "shutting down");
krb5_klog_close(kdc_context);
finish_realms(argv[0]);
+ if (kdc_realmlist)
+ free(kdc_realmlist);
+#ifdef USE_RCACHE
+ (void) krb5_rc_close(kdc_context, kdc_rcache);
+#endif
+#ifndef NOCACHE
+ kdc_free_lookaside();
+#endif
krb5_free_context(kcontext);
return errout;
}
#define DEL(set, idx) \
(set.data[idx] = set.data[--set.n], 0)
-#define FREE_SET_DATA(set) (free(set.data), set.data = 0, set.max = 0)
+#define FREE_SET_DATA(set) if(set.data) free(set.data); \
+ (set.data = 0, set.max = 0)
/* Set<struct connection *> connections; */
return;
}
+/* frees memory associated with the lookaside queue for memory profiling */
+void
+kdc_free_lookaside()
+{
+ register krb5_kdc_replay_ent *eptr, *last, *hold;
+ if (root_ptr.next) {
+ for (last = &root_ptr, eptr = root_ptr.next;
+ eptr; eptr = eptr->next) {
+ krb5_free_data(kdc_context, eptr->req_packet);
+ krb5_free_data(kdc_context, eptr->reply_packet);
+ krb5_free_address(kdc_context, eptr->addr);
+ hold = eptr;
+ last->next = eptr->next;
+ eptr = last;
+ free(hold);
+ }
+ }
+}
+
#endif /* NOCACHE */
ntrans.data = 0;
otrans.length = strlen(argv[1]);
- otrans.data = (char *) malloc(otrans.length);
+ if (otrans.length)
+ otrans.data = (char *) malloc(otrans.length);
+ else
+ otrans.data = 0;
memcpy(otrans.data,argv[1], otrans.length);
tgs = make_princ(kdc_context, argv[2], argv[0]);
printf("%s\n",ntrans.data);
/* Free up all memory so we can profile for leaks */
- free(otrans.data);
+ if (otrans.data)
+ free(otrans.data);
free(ntrans.data);
krb5_free_principal(kdc_realm.realm_context, tgs);