fix use after free
This commit is contained in:
parent
b2ca9fb81a
commit
e065c4f8ef
1 changed files with 3 additions and 1 deletions
4
libtel.c
4
libtel.c
|
@ -1,4 +1,5 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue