Skip to content

Commit f33b8d9

Browse files
authored
Merge pull request #4478 from notimaginative/fix_psnet_memory_error
fix memset() on nullptr in psnet_get_addr()
2 parents 2fd98c9 + bf1a9f1 commit f33b8d9

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)