Fix reference leak for negative dirents

PiperOrigin-RevId: 200306715
Change-Id: I7c80059c77ebd3d9a5d7d48b05c8e7a597f10850
This commit is contained in:
Ian Gudger
2018-06-12 17:04:20 -07:00
committed by Shentubot
parent c2b3f04d1c
commit ba426f7782
+9
View File
@@ -1257,6 +1257,15 @@ func (d *Dirent) destroy() {
// Drop all weak references.
for _, w := range d.children {
if c := w.Get(); c != nil {
if c.(*Dirent).IsNegative() {
// The parent holds both weak and strong refs in the case of
// negative dirents.
c.DecRef()
}
// Drop the reference we just acquired in WeakRef.Get.
c.DecRef()
}
w.Drop()
}
d.children = nil