From dadd9f9cb076688f0377840dcc657484de773391 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 30 Jun 2026 13:59:40 +0300 Subject: Fix chat::get_user UB (fell off non-void function on a miss) chat::get_user(string&, bool&) returned the user only when found and fell off the end of the non-void function on a miss (undefined behavior; compiler warns 'control reaches end of non-void function'). The 1-arg overload inherits the same UB. All callers check b_found before using the pointer, so add an explicit 'return NULL' on the not-found path to make the return well-defined. (The 1-arg overload appears unused - left in place, now safe via this fix.) Verified: normal chat still works, no crash. --- ychat/src/chat/chat.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ychat/src/chat/chat.cpp b/ychat/src/chat/chat.cpp index 8910a80..e6d39b6 100644 --- a/ychat/src/chat/chat.cpp +++ b/ychat/src/chat/chat.cpp @@ -87,6 +87,8 @@ chat::get_user( string &s_user, bool &b_found ) if ( *( (bool*) param.elem[1] ) ) return (user*) param.elem[2]; + + return NULL; // not found: defined return (callers check b_found first) } void -- cgit v1.2.3