diff options
author | Peter Zhu <peter@peterzhu.ca> | 2023-06-29 16:31:35 -0400 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2023-06-30 09:13:31 -0400 |
commit | 58386814a7c7275f66ffa111175fca2fe307a1b5 (patch) | |
tree | 56bfd1daec3a6d83dfda64b569de1b9fbbb4d23c /ext | |
parent | 37a893d12915b8860f6880d6a0c2859e096ab4ff (diff) | |
download | ruby-58386814a7c7275f66ffa111175fca2fe307a1b5.tar.gz |
Don't check for null pointer in calls to free
According to the C99 specification section 7.20.3.2 paragraph 2:
> If ptr is a null pointer, no action occurs.
So we do not need to check that the pointer is a null pointer.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/socket/getaddrinfo.c | 3 | ||||
-rw-r--r-- | ext/socket/socket.c | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c index 95a2feb3be..bf0d90129f 100644 --- a/ext/socket/getaddrinfo.c +++ b/ext/socket/getaddrinfo.c @@ -219,8 +219,7 @@ freeaddrinfo(struct addrinfo *ai) do { next = ai->ai_next; - if (ai->ai_canonname) - free(ai->ai_canonname); + free(ai->ai_canonname); /* no need to free(ai->ai_addr) */ free(ai); } while ((ai = next) != NULL); diff --git a/ext/socket/socket.c b/ext/socket/socket.c index eb74f7a936..74cb0644e6 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -1654,8 +1654,7 @@ socket_s_ip_address_list(VALUE self) finish: save_errno = errno; - if (lc.lifc_buf != NULL) - xfree(lc.lifc_req); + xfree(lc.lifc_req); if (fd != -1) close(fd); errno = save_errno; |