diff options
author | Ken Raeburn <raeburn@mit.edu> | 2008-06-21 00:06:52 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2008-06-21 00:06:52 +0000 |
commit | 10724c59079cf80a586bdd28de3bf6618b9a926c (patch) | |
tree | dfcd3ed489d3c53c0680d9e562e5aba89226155a | |
parent | d0bed0fc86f4918fa859181bc395cdd291f6b381 (diff) | |
download | krb5-10724c59079cf80a586bdd28de3bf6618b9a926c.zip krb5-10724c59079cf80a586bdd28de3bf6618b9a926c.tar.gz krb5-10724c59079cf80a586bdd28de3bf6618b9a926c.tar.bz2 |
Don't bother with null pointer checks before calling free
git-svn-id: svn://anonsvn.mit.edu/krb5/branches/sun-iprop@20453 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r-- | src/kadmin/server/ipropd_svc.c | 18 | ||||
-rw-r--r-- | src/lib/kdb/kdb5.c | 6 | ||||
-rw-r--r-- | src/lib/kdb/kdb_convert.c | 47 | ||||
-rw-r--r-- | src/lib/kdb/kdb_log.c | 6 | ||||
-rw-r--r-- | src/slave/kproplog.c | 3 |
5 files changed, 26 insertions, 54 deletions
diff --git a/src/kadmin/server/ipropd_svc.c b/src/kadmin/server/ipropd_svc.c index 17241e6..aeb63cb 100644 --- a/src/kadmin/server/ipropd_svc.c +++ b/src/kadmin/server/ipropd_svc.c @@ -211,10 +211,8 @@ iprop_get_updates_1_svc(kdb_last_t *arg, struct svc_req *rqstp) out: if (nofork) debprret(whoami, ret.ret, ret.lastentry.last_sno); - if (client_name) - free(client_name); - if (service_name) - free(service_name); + free(client_name); + free(service_name); return (&ret); } @@ -417,16 +415,12 @@ iprop_full_resync_1_svc(/* LINTED */ void *argp, struct svc_req *rqstp) out: if (nofork) debprret(whoami, ret.ret, 0); - if (client_name) - free(client_name); - if (service_name) - free(service_name); + free(client_name); + free(service_name); if (name) gss_release_name(&min_stat, &name); - if (tmpf) - free(tmpf); - if (ubuf) - free(ubuf); + free(tmpf); + free(ubuf); return (&ret); } diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c index ba486fa..af8bb89 100644 --- a/src/lib/kdb/kdb5.c +++ b/src/lib/kdb/kdb5.c @@ -1127,11 +1127,7 @@ err_lock: free_db_args(kcontext, db_args); if (log_ctx && (log_ctx->iproprole == IPROP_MASTER)) - /* - * XXX Bad deref in error case (malloc fail while creating - * array entries). --KR - */ - ulog_free_entries(fupd, *nentries); + ulog_free_entries(fupd, *nentries); return status; } diff --git a/src/lib/kdb/kdb_convert.c b/src/lib/kdb/kdb_convert.c index a35aeb8..61b2b97 100644 --- a/src/lib/kdb/kdb_convert.c +++ b/src/lib/kdb/kdb_convert.c @@ -597,8 +597,7 @@ ulog_conv_2logentry(krb5_context context, krb5_db_entry *entries, } - if (attr_types) - free(attr_types); + free(attr_types); /* * Update len field in kdb_update @@ -890,8 +889,7 @@ ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates) /* * ulog entry - kdb_princ_name */ - if (upd->kdb_princ_name.utf8str_t_val) - free(upd->kdb_princ_name.utf8str_t_val); + free(upd->kdb_princ_name.utf8str_t_val); /* BEGIN CSTYLED */ @@ -899,24 +897,20 @@ ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates) * ulog entry - kdb_kdcs_seen_by */ if (upd->kdb_kdcs_seen_by.kdb_kdcs_seen_by_val) { - for (i = 0; i < upd->kdb_kdcs_seen_by.kdb_kdcs_seen_by_len; i++) { - if (upd->kdb_kdcs_seen_by.kdb_kdcs_seen_by_val[i].utf8str_t_val) - free(upd->kdb_kdcs_seen_by.kdb_kdcs_seen_by_val[i].utf8str_t_val); - } - if (upd->kdb_kdcs_seen_by.kdb_kdcs_seen_by_val) - free(upd->kdb_kdcs_seen_by.kdb_kdcs_seen_by_val); + for (i = 0; i < upd->kdb_kdcs_seen_by.kdb_kdcs_seen_by_len; i++) + free(upd->kdb_kdcs_seen_by.kdb_kdcs_seen_by_val[i].utf8str_t_val); + free(upd->kdb_kdcs_seen_by.kdb_kdcs_seen_by_val); } /* * ulog entry - kdb_futures */ - if (upd->kdb_futures.kdb_futures_val) - free(upd->kdb_futures.kdb_futures_val); + free(upd->kdb_futures.kdb_futures_val); /* * ulog entry - kdb_update */ - if(upd->kdb_update.kdbe_t_val) { + if (upd->kdb_update.kdbe_t_val) { /* * Loop thru all the attributes and free up stuff */ @@ -928,12 +922,10 @@ ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates) if ((ULOG_ENTRY_TYPE(upd, i).av_type == AT_KEYDATA) && ULOG_ENTRY(upd, i).av_keydata.av_keydata_val) { for (j = 0; j < ULOG_ENTRY(upd, i).av_keydata.av_keydata_len; j++) { - if (ULOG_ENTRY_KEYVAL(upd, i, j).k_enctype.k_enctype_val) - free(ULOG_ENTRY_KEYVAL(upd, i, j).k_enctype.k_enctype_val); + free(ULOG_ENTRY_KEYVAL(upd, i, j).k_enctype.k_enctype_val); if (ULOG_ENTRY_KEYVAL(upd, i, j).k_contents.k_contents_val) { for (k = 0; k < ULOG_ENTRY_KEYVAL(upd, i, j).k_ver; k++) { - if (ULOG_ENTRY_KEYVAL(upd, i, j).k_contents.k_contents_val[k].utf8str_t_val) - free(ULOG_ENTRY_KEYVAL(upd, i, j).k_contents.k_contents_val[k].utf8str_t_val); + free(ULOG_ENTRY_KEYVAL(upd, i, j).k_contents.k_contents_val[k].utf8str_t_val); } free(ULOG_ENTRY_KEYVAL(upd, i, j).k_contents.k_contents_val); } @@ -947,8 +939,7 @@ ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates) */ if ((ULOG_ENTRY_TYPE(upd, i).av_type == AT_TL_DATA) && ULOG_ENTRY(upd, i).av_tldata.av_tldata_val) { for (j = 0; j < ULOG_ENTRY(upd, i).av_tldata.av_tldata_len; j++) { - if (ULOG_ENTRY(upd, i).av_tldata.av_tldata_val[j].tl_data.tl_data_val) - free(ULOG_ENTRY(upd, i).av_tldata.av_tldata_val[j].tl_data.tl_data_val); + free(ULOG_ENTRY(upd, i).av_tldata.av_tldata_val[j].tl_data.tl_data_val); } free(ULOG_ENTRY(upd, i).av_tldata.av_tldata_val); } @@ -957,12 +948,10 @@ ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates) * Free av_princ */ if (ULOG_ENTRY_TYPE(upd, i).av_type == AT_PRINC) { - if (ULOG_ENTRY(upd, i).av_princ.k_realm.utf8str_t_val) - free(ULOG_ENTRY(upd, i).av_princ.k_realm.utf8str_t_val); + free(ULOG_ENTRY(upd, i).av_princ.k_realm.utf8str_t_val); if (ULOG_ENTRY(upd, i).av_princ.k_components.k_components_val) { for (j = 0; j < ULOG_ENTRY(upd, i).av_princ.k_components.k_components_len; j++) { - if (ULOG_ENTRY_PRINC(upd, i, j).k_data.utf8str_t_val) - free(ULOG_ENTRY_PRINC(upd, i, j).k_data.utf8str_t_val); + free(ULOG_ENTRY_PRINC(upd, i, j).k_data.utf8str_t_val); } free(ULOG_ENTRY(upd, i).av_princ.k_components.k_components_val); } @@ -972,12 +961,10 @@ ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates) * Free av_mod_princ */ if (ULOG_ENTRY_TYPE(upd, i).av_type == AT_MOD_PRINC) { - if (ULOG_ENTRY(upd, i).av_mod_princ.k_realm.utf8str_t_val) - free(ULOG_ENTRY(upd, i).av_mod_princ.k_realm.utf8str_t_val); + free(ULOG_ENTRY(upd, i).av_mod_princ.k_realm.utf8str_t_val); if (ULOG_ENTRY(upd, i).av_mod_princ.k_components.k_components_val) { for (j = 0; j < ULOG_ENTRY(upd, i).av_mod_princ.k_components.k_components_len; j++) { - if (ULOG_ENTRY_MOD_PRINC(upd, i, j).k_data.utf8str_t_val) - free(ULOG_ENTRY_MOD_PRINC(upd, i, j).k_data.utf8str_t_val); + free(ULOG_ENTRY_MOD_PRINC(upd, i, j).k_data.utf8str_t_val); } free(ULOG_ENTRY(upd, i).av_mod_princ.k_components.k_components_val); } @@ -1011,8 +998,7 @@ ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates) /* * Free up the pointer to kdbe_t_val */ - if (upd->kdb_update.kdbe_t_val) - free(upd->kdb_update.kdbe_t_val); + free(upd->kdb_update.kdbe_t_val); } /* END CSTYLED */ @@ -1027,6 +1013,5 @@ ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates) /* * Finally, free up the pointer to the bunched ulog entries */ - if (updates) - free(updates); + free(updates); } diff --git a/src/lib/kdb/kdb_log.c b/src/lib/kdb/kdb_log.c index 14e058b..3bfaadc 100644 --- a/src/lib/kdb/kdb_log.c +++ b/src/lib/kdb/kdb_log.c @@ -359,8 +359,7 @@ ulog_replay(krb5_context context, kdb_incr_result_t *incr_ret, char **db_args) goto cleanup; } - if (dbprincstr) - free(dbprincstr); + free(dbprincstr); retval = krb5int_delete_principal_no_log(context, dbprinc, @@ -510,8 +509,7 @@ error: if (upd) ulog_free_entries(upd, 1); - if (incr_ret) - free(incr_ret); + free(incr_ret); ulog_sync_header(ulog); diff --git a/src/slave/kproplog.c b/src/slave/kproplog.c index f7066ea..58ce70f 100644 --- a/src/slave/kproplog.c +++ b/src/slave/kproplog.c @@ -186,8 +186,7 @@ print_update(kdb_hlog_t *ulog, uint32_t entry, bool_t verbose) upd.kdb_update.kdbe_t_val[j].av_type); xdr_free(xdr_kdb_incr_update_t, (char *)&upd); - if (dbprinc) - free(dbprinc); + free(dbprinc); } /* for */ } |