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:
Enji Cooper 2016-12-30 23:44:39 +00:00
parent d481a92572
commit 8373993535
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=310873

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;
}