From: Christian Grothoff Date: Tue, 21 Feb 2017 09:41:53 +0000 (+0100) Subject: prevent crash on exit X-Git-Tag: taler-0.2.1~116 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=aad47a3092ff6139902c28d84d4e53453ade6343;p=oweals%2Fgnunet.git prevent crash on exit --- diff --git a/src/cadet/cadet_api_new.c b/src/cadet/cadet_api_new.c index 7ed681a9d..100c02a69 100644 --- a/src/cadet/cadet_api_new.c +++ b/src/cadet/cadet_api_new.c @@ -1244,7 +1244,7 @@ GNUNET_CADET_close_port (struct GNUNET_CADET_Port *p) GNUNET_CONTAINER_multihashmap_remove (p->cadet->ports, &p->id, p)); - GNUNET_free (p->handlers); + GNUNET_free_non_null (p->handlers); GNUNET_free (p); } diff --git a/src/util/service_new.c b/src/util/service_new.c index 8d654c0cb..1b3254cca 100644 --- a/src/util/service_new.c +++ b/src/util/service_new.c @@ -1624,17 +1624,7 @@ GNUNET_SERVICE_starT (const char *service_name, sh->connect_cb = connect_cb; sh->disconnect_cb = disconnect_cb; sh->cb_cls = cls; - if (NULL != handlers) - { - unsigned int i; - - for (i=0;NULL != handlers[i].cb; i++) ; - sh->handlers = GNUNET_new_array (i + 1, - struct GNUNET_MQ_MessageHandler); - GNUNET_memcpy (sh->handlers, - handlers, - i * sizeof (struct GNUNET_MQ_MessageHandler)); - } + sh->handlers = GNUNET_MQ_copy_handlers (handlers); if (GNUNET_OK != setup_service (sh)) { GNUNET_free (sh->handlers); @@ -1660,7 +1650,7 @@ GNUNET_SERVICE_stoP (struct GNUNET_SERVICE_Handle *srv) while (NULL != (client = srv->clients_head)) GNUNET_SERVICE_client_drop (client); teardown_service (srv); - GNUNET_free (srv->handlers); + GNUNET_free_non_null (srv->handlers); GNUNET_free (srv); } @@ -1762,17 +1752,7 @@ GNUNET_SERVICE_ruN_ (int argc, sh.connect_cb = connect_cb; sh.disconnect_cb = disconnect_cb; sh.cb_cls = cls; - if (NULL != handlers) - { - unsigned int i; - - for (i=0;NULL != handlers[i].cb; i++) ; - sh.handlers = GNUNET_new_array (i + 1, - struct GNUNET_MQ_MessageHandler); - GNUNET_memcpy (sh.handlers, - handlers, - i * sizeof (struct GNUNET_MQ_MessageHandler)); - } + sh.handlers = GNUNET_MQ_copy_handlers (handlers); sh.service_name = service_name; /* setup subsystems */ @@ -1903,7 +1883,7 @@ shutdown: } #endif teardown_service (&sh); - GNUNET_free (sh.handlers); + GNUNET_free_non_null (sh.handlers); GNUNET_SPEEDUP_stop_ (); GNUNET_CONFIGURATION_destroy (cfg); GNUNET_free_non_null (logfile);