Skip to content

Commit 7fd9dd6

Browse files
yfeldblumfacebook-github-bot
authored andcommitted
fix nullptr-dereference in SocketAddress
Summary: When `getaddrinfo` fails, `SocketAddress` attempts to describe the error and throw an exception with that description. It includes the `gai_strerror`, which is a C-string, without checking whether the result is nullptr. On linux it is not `nullptr` but you never know. Reviewed By: knekritz Differential Revision: D70713343 fbshipit-source-id: 8d6c3710e51610a1ca43886f668941f5e4713054
1 parent e43ee69 commit 7fd9dd6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

folly/SocketAddress.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct GetAddrInfoError {
115115
}
116116
#else
117117
const char* error;
118-
const char* str() const { return error; }
118+
const char* str() const { return error ? error : "Unknown error"; }
119119
explicit GetAddrInfoError(int errorCode) : error(gai_strerror(errorCode)) {}
120120
#endif
121121
};

0 commit comments

Comments
 (0)