init_list_entry(&cd->node);
cd->codec = codec;
list_add_tail(&cd->node, &client->codecs);
init_list_entry(&cd->node);
cd->codec = codec;
list_add_tail(&cd->node, &client->codecs);
init_list_entry(&token->node);
token->token = strdup(token_string);
if (token->token == NULL)
init_list_entry(&token->node);
token->token = strdup(token_string);
if (token->token == NULL)
memset(cd, 0, sizeof(codec_t));
init_list_entry(&cd->node);
cd->codec = codec_itr->codec;
memset(cd, 0, sizeof(codec_t));
init_list_entry(&cd->node);
cd->codec = codec_itr->codec;
- if ((newclient = calloc(1, sizeof(client_t))) == NULL)
- Log_fatal("(%s:%s): Out of memory while allocating %d bytes.", __FILE__, __LINE__, sizeof(client_t));
+ newclient = Memory_safeCalloc(1, sizeof(client_t));
newclient->tcpfd = fd;
memcpy(&newclient->remote_tcp, remote, sizeof(struct sockaddr_storage));
newclient->ssl = SSLi_newconnection(&newclient->tcpfd, &newclient->SSLready);
if (newclient->ssl == NULL) {
newclient->tcpfd = fd;
memcpy(&newclient->remote_tcp, remote, sizeof(struct sockaddr_storage));
newclient->ssl = SSLi_newconnection(&newclient->tcpfd, &newclient->SSLready);
if (newclient->ssl == NULL) {
- Log_warn("SSL negotiation failed with %s on port %d", Util_addressToString(remote), Util_addressToPort(remote));
+ addressString = Util_addressToString(remote);
+ Log_warn("SSL negotiation failed with %s on port %d", addressString, Util_addressToPort(remote));
+ free(addressString);
- message = malloc(strlen(text) + 1);
- if (!message)
- Log_fatal("Out of memory");
- tree_id = malloc(sizeof(uint32_t));
- if (!tree_id)
- Log_fatal("Out of memory");
+ message = Memory_safeMalloc(1, strlen(text) + 1);
+ tree_id = Memory_safeMalloc(1, sizeof(uint32_t));
if (memcmp(itraddress, fromaddress, addresslength) == 0) {
if (checkDecrypt(itr, encrypted, buffer, len)) {
memcpy(itr->key, key, KEY_LENGTH);
if (memcmp(itraddress, fromaddress, addresslength) == 0) {
if (checkDecrypt(itr, encrypted, buffer, len)) {
memcpy(itr->key, key, KEY_LENGTH);
- Log_info_client(itr, "New UDP connection from %s on port %d", Util_clientAddressToString(itr), fromport);
+ char* clientAddressString = Util_clientAddressToString(itr);
+ Log_info_client(itr, "New UDP connection from %s on port %d", clientAddressString, fromport);
+ free(clientAddressString);
- Log_debug("Unknown UDP message type from %s port %d", Util_clientAddressToString(itr), fromport);
+ clientAddressString = Util_clientAddressToString(itr);
+ Log_debug("Unknown UDP message type from %s port %d", clientAddressString, fromport);
+ free(clientAddressString);
CryptState_encrypt(&client->cryptState, data, buf, len);
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
CryptState_encrypt(&client->cryptState, data, buf, len);
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)