summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-30 13:59:40 +0300
committerPaul Buetow <paul@buetow.org>2026-06-30 13:59:40 +0300
commitdadd9f9cb076688f0377840dcc657484de773391 (patch)
tree68d316cf22fba0ff284c87412f530b7a66b49023
parentfed8e7b6d78c39b8a53af6f6c98188bc4d3c97c9 (diff)
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.
-rw-r--r--ychat/src/chat/chat.cpp2
1 files changed, 2 insertions, 0 deletions
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