Skip to content

Commit

Permalink
src: use sizeof(var) instead of sizeof(type)
Browse files Browse the repository at this point in the history
Change `memset(&s, 0, sizeof(type))` to `memset(&s, 0, sizeof(s))`.
The former is dangerous when the type of `s` changes.

PR-URL: #27038
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
  • Loading branch information
bnoordhuis authored and BethGriggs committed Apr 4, 2019
1 parent a1d1b4c commit 23f53e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
args[4]->IsTrue());

struct addrinfo hints;
memset(&hints, 0, sizeof(struct addrinfo));
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = flags;
Expand Down

0 comments on commit 23f53e8

Please sign in to comment.