Skip to content

Commit bf1a9f1

Browse files
fix memset() on nullptr in psnet_get_addr()
"addr" is optional and allowed to be null, so we've got to check it before zeroing
1 parent 0ab523b commit bf1a9f1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

code/network/psnet2.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,11 @@ bool psnet_get_addr(const char *host, const char *port, SOCKADDR_STORAGE *addr,
11511151
SOCKADDR_IN6 si4to6;
11521152
int rval;
11531153

1154-
memset(addr, 0, sizeof(*addr));
1154+
if (addr) {
1155+
// by the spec, sockaddr_in6 must be zero'd, so just do that always
1156+
memset(addr, 0, sizeof(*addr));
1157+
}
1158+
11551159
memset(&si4to6, 0, sizeof(si4to6));
11561160

11571161
memset(&hints, 0, sizeof(hints));

0 commit comments

Comments
 (0)