ps-lite icon indicating copy to clipboard operation
ps-lite copied to clipboard

GetAvailablePort function

Open microwish opened this issue 8 years ago • 0 comments

src/network_utils.h:

Perhaps two issues on the function GetAvailablePort.

First of all, although it doesn't affect the expected behavior of the function GetAvailablePort, it might be better to return -1 instead of 0 if there is any error. After all, port 0 is reserved by TCP/IP suite. If this function returns -1 instead of 0, CHECK() should also be replaced by CHECH_LT().

Second, necessary calls to close(sock) are missing when there are errors amid, so memory leak might happen in some corner cases.

microwish avatar Mar 26 '17 18:03 microwish