const SilcBufferStruct packet;
int block_len;
SilcUInt32 sequence = 0;
+ int src_id_allocated = FALSE;
if (!sock)
return;
} else {
packetdata.src_id = silc_calloc(SILC_ID_CLIENT_LEN, sizeof(unsigned char));
packetdata.src_id_len = SILC_ID_CLIENT_LEN;
+ src_id_allocated = TRUE;
}
packetdata.src_id_type = SILC_ID_CLIENT;
if (dst_id) {
if (!silc_packet_assemble(&packetdata, client->rng, cipher, hmac, sock,
data, data_len, (const SilcBuffer)&packet)) {
SILC_LOG_ERROR(("Error assembling packet"));
- return;
+ goto out;
}
/* Encrypt the packet */
/* Now actually send the packet */
silc_client_packet_send_real(client, sock, force_send);
+
+ out:
+ if (src_id_allocated && packetdata.src_id)
+ silc_free(packetdata.src_id);
+ if (packetdata.dst_id)
+ silc_free(packetdata.dst_id);
}
/* Packet sending routine for application. This is the only routine that
silc_buffer_free(sidp);
if (!conn->internal->params.detach_data) {
- /* Send NICK command if the nickname was set by the application.
- Send this with little timeout. */
- if (client->nickname)
+ /* Send NICK command if the nickname was set by the application (and is
+ not same as the username). Send this with little timeout. */
+ if (client->nickname &&
+ !silc_utf8_strcasecmp(client->nickname, client->username))
silc_schedule_task_add(client->schedule, 0,
silc_client_send_auto_nick, conn,
1, 0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);