Fix potential memory leak on Windows

This commit is contained in:
Joseph C. Lehner 2016-11-19 20:19:45 +01:00
parent 8f5a628b01
commit b9504f17c8

View file

@ -276,12 +276,6 @@ struct ethsock *ethsock_create(const char *intf, uint16_t protocol)
struct ethsock *sock;
int err;
sock = malloc(sizeof(struct ethsock));
if (!sock) {
perror("malloc");
return NULL;
}
#ifdef NMRPFLASH_WINDOWS
intf = intf_alias_to_wpcap(intf);
if (!intf) {
@ -289,6 +283,12 @@ struct ethsock *ethsock_create(const char *intf, uint16_t protocol)
}
#endif
sock = malloc(sizeof(struct ethsock));
if (!sock) {
perror("malloc");
return NULL;
}
buf[0] = '\0';
sock->intf = intf;