libc/netdb: fix memory leak in freeaddrinfo()
authorWonsang Ryou <wonsang.yoo@samsung.com>
Fri, 31 Mar 2017 07:27:35 +0000 (16:27 +0900)
committerHeesub Shin <heesub.shin@samsung.com>
Tue, 18 Apr 2017 03:02:04 +0000 (12:02 +0900)
This patch fixes the memory leak problem in freeaddrinfo().

In freeaddrinfo(), ai->ai_canonname is not freed even if it is
allocated by getaddrinfo(). So it will cause memory leak.

Change-Id: Iede7ad7380f92db07fc1e581984557ebea3d308e
Signed-off-by: Wonsang Ryou <wonsang.yoo@samsung.com>
lib/libc/netdb/lib_getaddrinfo.c

index 4c61de5..8f7808d 100644 (file)
@@ -283,6 +283,9 @@ void freeaddrinfo(struct addrinfo *ai)
                if (!ai->ai_addr) {
                        free(ai->ai_addr);
                }
+               if (ai->ai_canonname) {
+                       free(ai->ai_canonname);
+               }
                free(ai);
                ai = next;
        }