diff options
author | Martijn van Duren <martijn@cvs.openbsd.org> | 2020-09-29 14:23:55 +0000 |
---|---|---|
committer | Martijn van Duren <martijn@cvs.openbsd.org> | 2020-09-29 14:23:55 +0000 |
commit | 01acb58b8a1691f5c44531ef7f8199ae39208aba (patch) | |
tree | 383edf6701cb90f1d8c87b97104e350a205675e2 /usr.sbin/relayd | |
parent | 3a5779fe0fbe6d5a13603f001f76fb5c66591fe2 (diff) |
Sync with libagentx
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r-- | usr.sbin/relayd/subagentx.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.sbin/relayd/subagentx.c b/usr.sbin/relayd/subagentx.c index 6c392a1cb63..ccb9684196b 100644 --- a/usr.sbin/relayd/subagentx.c +++ b/usr.sbin/relayd/subagentx.c @@ -1729,6 +1729,7 @@ void subagentx_index_free(struct subagentx_index *sai) { size_t i; + struct subagentx_object *sao; if (sai == NULL) return; @@ -1737,14 +1738,18 @@ subagentx_index_free(struct subagentx_index *sai) subagentx_log_sac_fatalx(sai->sai_sar->sar_sac, "%s: double free", __func__); - sai->sai_dstate = SA_DSTATE_CLOSE; - /* TODO Do a range_subid unregister before freeing */ for (i = 0; i < sai->sai_objectlen; i++) { - if (sai->sai_object[i]->sao_dstate != SA_DSTATE_CLOSE) - subagentx_object_free(sai->sai_object[i]); + sao = sai->sai_object[i]; + if (sao->sao_dstate != SA_DSTATE_CLOSE) { + subagentx_object_free(sao); + if (sai->sai_object[i] != sao) + i--; + } } + sai->sai_dstate = SA_DSTATE_CLOSE; + if (sai->sai_cstate == SA_CSTATE_OPEN) (void) subagentx_index_close(sai); else if (sai->sai_cstate == SA_CSTATE_CLOSE) @@ -2415,7 +2420,8 @@ subagentx_object_free_finalize(struct subagentx_object *sao) "%s: object not found in index", __func__); #endif sao->sao_index[i]->sai_objectlen--; - if (sao->sao_index[i]->sai_dstate == SA_DSTATE_CLOSE) + if (sao->sao_index[i]->sai_dstate == SA_DSTATE_CLOSE && + sao->sao_index[i]->sai_cstate == SA_CSTATE_CLOSE) subagentx_index_free_finalize(sao->sao_index[i]); } |