We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
strdup
malloc
strcpy
1 parent 04439c6 commit 5e8b27aCopy full SHA for 5e8b27a
1 file changed
ext/socket/getaddrinfo.c
@@ -171,9 +171,7 @@ static const char *const ai_errlist[] = {
171
172
#define GET_CANONNAME(ai, str) \
173
if (pai->ai_flags & AI_CANONNAME) {\
174
- if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\
175
- strcpy((ai)->ai_canonname, (str));\
176
- } else {\
+ if (((ai)->ai_canonname = strdup(str)) == NULL) {\
177
error = EAI_MEMORY;\
178
goto free;\
179
}\
0 commit comments