Null a pointer after it is freed so that when it is returned

the return value is NULL. Based on the returned flags, the
return value should never be inspected in the case where NULL
is returned, but it is good coding practice not to return a
pointer to freed memory.

Found by:    Coverity Scan, CID 1006096
Reviewed by: kib
MFC after:   2 weeks
This commit is contained in:
Kirk McKusick 2013-05-22 00:40:26 +00:00
parent 64e2b0887c
commit d80dbbdb4a

View File

@ -8150,6 +8150,7 @@ setup_newdir(dap, newinum, dinum, newdirbp, mkdirp)
(inodedep->id_state & ALLCOMPLETE) == ALLCOMPLETE) {
dap->da_state &= ~MKDIR_PARENT;
WORKITEM_FREE(mkdir2, D_MKDIR);
mkdir2 = NULL;
} else {
LIST_INSERT_HEAD(&mkdirlisthd, mkdir2, md_mkdirs);
WORKLIST_INSERT(&inodedep->id_bufwait, &mkdir2->md_list);