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 <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
  • Loading branch information
bnoordhuis authored and BethGriggs committed Apr 9, 2019
1 parent 100bfc5 commit 32ec034
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 32ec034

Please sign in to comment.