gemini-code-assist[bot] commented on code in PR #19662:
URL: https://github.com/apache/tvm/pull/19662#discussion_r3349474467


##########
src/support/socket.h:
##########
@@ -133,6 +133,9 @@ struct SockAddr {
    * \param port the port of address
    */
   void Set(const char* host, int port) {
+    if (strcmp(host, "localhost") == 0) {
+      host = "127.0.0.1";
+    }

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   The `host` parameter can be `nullptr` (for example, when binding to all 
interfaces using wildcard addresses with `AI_PASSIVE`). Calling `strcmp` on a 
`nullptr` will result in a segmentation fault (undefined behavior). A null 
check should be added before performing the comparison.
   
   ```suggestion
       if (host != nullptr && strcmp(host, "localhost") == 0) {
         host = "127.0.0.1";
       }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to