diff options
author | Yorhel <git@yorhel.nl> | 2013-05-01 10:40:30 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2013-05-01 10:40:30 +0200 |
commit | 62f3395d27ed8c2ce06cb0c6ab0c5fed476ae027 (patch) | |
tree | 9a787c928bcb195933128660ecf7eb6eb0dc3fbd | |
parent | abd84783d1f65dd76bdcfd89a5bb1c31528e4528 (diff) |
hub/adc: Fix possible double-free of last INF values
-rw-r--r-- | src/hub/adc.c | 8 | ||||
-rw-r--r-- | src/hub/adc.h | 1 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/hub/adc.c b/src/hub/adc.c index aa7d2d6..1382386 100644 --- a/src/hub/adc.c +++ b/src/hub/adc.c @@ -84,8 +84,10 @@ static void hub_adc_sendinf(hub_t *h) { if(f || n.HR != o->HR) adc_appendf(&msg, "HR%"PRIu16, n.HR); if(f || n.HO != o->HO) adc_appendf(&msg, "HO%"PRIu16, n.HO); - if(!f) + if(h->a.havelastinf) hub_adc_myinf_free(o); + else + h->a.havelastinf = true; h->a.lastinf = n; /* Don't send an INF if nothing has changed */ @@ -629,6 +631,7 @@ static bool hub_adc_chat(hub_t *h, hub_user_t *u, const char *message, bool me) static void hub_adc_connected(hub_t *h) { kstring_t msg = {}; h->a.state = ADC_PROTOCOL; + h->a.havelastinf = false; adc_create(&msg, 'H', ADC_CMD_SUP, 0, 0); adc_append(&msg, "ADBASE"); @@ -639,7 +642,8 @@ static void hub_adc_connected(hub_t *h) { static void hub_adc_disconnected(hub_t *h) { - hub_adc_myinf_free(&h->a.lastinf); + if(h->a.havelastinf) + hub_adc_myinf_free(&h->a.lastinf); hub_manager_settype(h, HUBM_HNONE); } diff --git a/src/hub/adc.h b/src/hub/adc.h index 8241eb7..4ac99c2 100644 --- a/src/hub/adc.h +++ b/src/hub/adc.h @@ -39,6 +39,7 @@ typedef struct { adc_state_t state; adc_sid_t mysid; hub_adc_myinf_t lastinf; + bool havelastinf : 1; bool zlibenable : 1; } hub_adc_t; |