Always close socket in error cases

Thanks to Thomas Jarosch <thomas.jarosch@intra2net.com> for fixing this
This commit is contained in:
Karsten Keil 2014-09-22 01:41:30 +02:00
parent 43cd10a657
commit 50b4970832
1 changed files with 4 additions and 1 deletions

View File

@ -107,11 +107,14 @@ open_layer3(unsigned int dev, unsigned int proto, unsigned int prop, mlayer3_cb_
/* handle version backward compatibility specific stuff here */
l3 = calloc(1, sizeof(struct _layer3));
if (!l3)
if (!l3) {
close(fd);
return NULL;
}
l3->ml3.devinfo = calloc(1, sizeof(*l3->ml3.devinfo));
if (!l3->ml3.devinfo) {
free(l3);
close(fd);
return NULL;
}
l3->ml3.options = prop;