Language: C
Label: vulnerable
CWE: CWE-401 \u2014 Missing Release of Memory after Effective Lifetime
The product does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory.

Code:
void client_reset(t_client *client)
{
	char *hash;
	char *msg;
	char *cidinfo;

	debug(LOG_DEBUG, "Resetting client [%s]", client->mac);
	// Reset traffic counters
	client->counters.incoming = 0;
	client->counters.outgoing = 0;
	client->counters.last_updated = time(NULL);

	// Reset session time
	client->session_start = 0;
	client->session_end = 0;

	// Reset token and hid
	hash = safe_calloc(STATUS_BUF);
	client->token = safe_calloc(STATUS_BUF);
	safe_snprintf(client->token, STATUS_BUF, "%04hx%04hx", rand16(), rand16());
	hash_str(hash, STATUS_BUF, client->token);
	client->hid = safe_strdup(hash);
	free(hash);

	// Reset custom and client_type
	client->custom = safe_calloc(MID_BUF);
	client->client_type = safe_calloc(STATUS_BUF);

	//Reset cid and remove cidfile using rmcid
	if (client->cid) {

		if (strlen(client->cid) > 0) {
			msg = safe_calloc(SMALL_BUF);
			cidinfo = safe_calloc(MID_BUF);
			safe_snprintf(cidinfo, MID_BUF, "cid=\"%s\"", client->cid);
			write_client_info(msg, SMALL_BUF, "rmcid", client->cid, cidinfo);
			free(msg);
			free(cidinfo);
		}

		client->cid = safe_calloc(SMALL_BUF);
	}

}