TNT/include
m1ngsama 298995aa53 Fix critical memory and concurrency bugs
Fixes three critical bugs that caused crashes after long-running:

1. Use-after-free race condition in room_broadcast()
   - Added reference counting to client_t structure
   - Increment ref_count before using client outside lock
   - Decrement and free only when ref_count reaches 0
   - Prevents accessing freed client memory during broadcast

2. strtok() data corruption in tui_render_command_output()
   - strtok() modifies original string by replacing delimiters
   - Now use a local copy before calling strtok()
   - Prevents corruption of client->command_output

3. Improved handle_key() consistency
   - Return bool to indicate if key was consumed
   - Fixes issue where mode-switch keys were processed twice

Thread safety changes:
- Added client->ref_count and client->ref_lock
- Added client_release() for safe cleanup
- room_broadcast() now properly increments/decrements refs

This fixes the primary cause of crashes during extended operation.
2025-11-30 09:00:00 +08:00
..
.gitkeep Initial commit 2025-07-01 09:00:00 +08:00
chat_room.h Initial commit 2025-07-01 09:00:00 +08:00
common.h Initial commit 2025-07-01 09:00:00 +08:00
message.h Initial commit 2025-07-01 09:00:00 +08:00
ssh_server.h Fix critical memory and concurrency bugs 2025-11-30 09:00:00 +08:00
tui.h Replace telnet with SSH and fix full-screen display 2025-11-24 16:48:14 +08:00
utf8.h Initial commit 2025-07-01 09:00:00 +08:00