diff --git a/src/memory_leak_debug.cpp b/src/memory_leak_debug.cpp index 6f5337a..ed0dca7 100644 --- a/src/memory_leak_debug.cpp +++ b/src/memory_leak_debug.cpp @@ -201,8 +201,9 @@ void memory_tracking_stop() uint64_t total_leaks = 0; for (uint32_t i = 0; i < N; ++i) { - if (allocations[i].allocated_size) { - total_leaks += allocations[i].allocated_size; + const TrackedAllocation& t = allocations[i]; + if (t.allocated_size) { + total_leaks += t.allocated_size; char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)] = {}; PSYMBOL_INFO pSymbol = reinterpret_cast(buffer); @@ -213,9 +214,9 @@ void memory_tracking_stop() IMAGEHLP_LINE64 line{}; line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); - printf("Memory leak detected, %u bytes allocated by thread %u at:\n", allocations[i].allocated_size, allocations[i].thread_id); + printf("Memory leak detected, %u bytes allocated at %p by thread %u:\n", t.allocated_size, t.p, t.thread_id); for (size_t j = 0; j < MAX_FRAMES; ++j) { - const DWORD64 address = reinterpret_cast(allocations[i].stack_trace[j]); + const DWORD64 address = reinterpret_cast(t.stack_trace[j]); DWORD64 t1 = 0; DWORD t2 = 0; if (SymFromAddr(h, address, &t1, pSymbol) && SymGetLineFromAddr64(h, address, &t2, &line)) { diff --git a/src/tcp_server.inl b/src/tcp_server.inl index 5fa445c..f860709 100644 --- a/src/tcp_server.inl +++ b/src/tcp_server.inl @@ -315,6 +315,7 @@ bool TCPServer::connect_to_peer(Client* client) if (!m_pendingConnections.insert(client->m_addr).second) { LOGINFO(6, "there is already a pending connection to this IP, not connecting to " << log::Gray() << static_cast(client->m_addrString)); + m_preallocatedClients.push_back(client); return false; }