Guard against use-after-free after calling mibif_free(..)

Set variables to NULL after calling free.

Also, remove unnecessary if (x != NULL) checks before calling free(x)

MFC after:	1 week
This commit is contained in:
ngie 2016-12-30 23:44:39 +00:00
parent cff1941413
commit c279beb25f

View File

@ -707,10 +707,11 @@ mibif_free(struct mibif *ifp)
}
free(ifp->private);
if (ifp->physaddr != NULL)
free(ifp->physaddr);
if (ifp->specmib != NULL)
free(ifp->specmib);
ifp->private = NULL;
free(ifp->physaddr);
ifp->physaddr = NULL;
free(ifp->specmib);
ifp->specmib = NULL;
STAILQ_FOREACH(map, &mibindexmap_list, link)
if (map->mibif == ifp) {
@ -745,8 +746,8 @@ mibif_free(struct mibif *ifp)
at = at1;
}
free(ifp);
ifp = NULL;
mib_if_number--;
mib_iftable_last_change = this_tick;
}