diff --git a/libtel.c b/libtel.c index 29e3779..fc18573 100644 --- a/libtel.c +++ b/libtel.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -54,8 +55,9 @@ int tel_get_addr(char *ip, char *port, struct sockaddr **addr, socklen_t *addr_l int res = getaddrinfo(ip, port, &hints, &info); if(res != 0) return res; - *addr = info->ai_addr; + *addr = malloc(info->ai_addrlen); *addr_len = info->ai_addrlen; + memcpy(*addr, info->ai_addr, info->ai_addrlen); freeaddrinfo(info); return 0;