Skip to content

Commit eae5537

Browse files
committed
fix: missing lock
I don't know what this code is supposed to do, but it's clearly accessing data once with a lock and then the same data without a lock. Add a second lock to fix this.
1 parent 9943e4c commit eae5537

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

toxcore/net_crypto.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,9 +1178,11 @@ static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_id, cons
11781178
if (send_data_packet_helper(c, crypt_connection_id, conn->recv_array.buffer_start, packet_num, data, length) == 0) {
11791179
Packet_Data *dt1 = nullptr;
11801180

1181+
pthread_mutex_lock(conn->mutex);
11811182
if (get_data_pointer(c->log, &conn->send_array, &dt1, packet_num) == 1) {
11821183
dt1->sent_time = current_time_monotonic(c->mono_time);
11831184
}
1185+
pthread_mutex_unlock(conn->mutex);
11841186
} else {
11851187
conn->maximum_speed_reached = 1;
11861188
LOGGER_DEBUG(c->log, "send_data_packet failed");

0 commit comments

Comments
 (0)