mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 15:16:21 +00:00
fix(ai): validate aiwin pointer to prevent UAF when window closed
Prevent use-after-free in the AI request worker thread when the user closes the AI window during the 60-second HTTP request timeout. Without this fix, the worker may dereference a dangling pointer and crash or exhibit undefined behavior. The _ai_request_thread function in ai_client.c previously cast user_data to ProfAiWin* and used it directly without verifying the window was still alive. Added wins_ai_exists() to iterate through all AI windows and check if the pointer is still valid before use. Safety: - wins_ai_exists() iterates all AI windows (handles multiple AI windows) - Worker skips UI update if window was freed, just cleans up - Logs warning when dangling pointer is detected
This commit is contained in:
@@ -64,6 +64,7 @@ ProfPluginWin* wins_get_plugin(const char* const tag);
|
||||
ProfXMLWin* wins_get_xmlconsole(void);
|
||||
ProfVcardWin* wins_get_vcard(void);
|
||||
ProfAiWin* wins_get_ai(void);
|
||||
gboolean wins_ai_exists(ProfAiWin* const aiwin);
|
||||
|
||||
void wins_close_plugin(char* tag);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user