diff options
| author | Roy Marples <roy@marples.name> | 2012-11-14 10:31:49 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2012-11-14 10:31:49 +0000 |
| commit | 2534ef40f282896d5803d38b8f4e561ce6e731e8 (patch) | |
| tree | c3b0d2a74c8331ef96e01d0129886ce9312c4821 | |
| parent | a8d26e9d7b4019a73aa28acc94a8f03e4c0c3781 (diff) | |
| download | dhcpcd-2534ef40f282896d5803d38b8f4e561ce6e731e8.tar.xz | |
Plug some memory leaks.
| -rw-r--r-- | dhcpcd.c | 8 | ||||
| -rw-r--r-- | eloop.c | 11 | ||||
| -rw-r--r-- | eloop.h | 1 |
3 files changed, 15 insertions, 5 deletions
@@ -825,7 +825,8 @@ configure_interface1(struct interface *iface) duid = xmalloc(DUID_LEN); if ((len = get_duid(duid, iface)) == 0) syslog(LOG_ERR, "get_duid: %m"); - } + } else + duid = NULL; if (len > 0) { iface->clientid = xmalloc(len + 6); iface->clientid[0] = len + 5; @@ -849,6 +850,7 @@ configure_interface1(struct interface *iface) memcpy(iface->clientid + 2, iface->hwaddr, iface->hwlen); } + free(duid); } if (ifo->options & DHCPCD_CLIENTID) syslog(LOG_DEBUG, "%s: using ClientID %s", iface->name, @@ -1994,6 +1996,10 @@ main(int argc, char **argv) syslog(LOG_INFO, "version " VERSION " starting"); +#ifdef DEBUG_MEMORY + eloop_init(); +#endif + if ((signal_fd = signal_init()) == -1) exit(EXIT_FAILURE); if (signal_setup() == -1) @@ -276,6 +276,13 @@ cleanup(void) } free(fds); } + +void +eloop_init(void) +{ + + atexit(cleanup); +} #endif _noreturn void @@ -287,10 +294,6 @@ start_eloop(void) struct timeout *t; struct timeval tv; -#ifdef DEBUG_MEMORY - atexit(cleanup); -#endif - for (;;) { /* Run all timeouts first. * When we have one that has not yet occured, @@ -46,6 +46,7 @@ void add_q_timeout_tv(int queue, const struct timeval *, void (*)(void *), void *); void delete_q_timeout(int, void (*)(void *), void *); void delete_q_timeouts(int, void *, void (*)(void *), ...); +void eloop_init(void); void start_eloop(void); #endif |
