Explorar el Código

check for double release

Darien Raymond hace 8 años
padre
commit
5769df496b
Se han modificado 1 ficheros con 8 adiciones y 4 borrados
  1. 8 4
      common/bufio/writer.go

+ 8 - 4
common/bufio/writer.go

@@ -85,11 +85,15 @@ func (v *BufferedWriter) SetCached(cached bool) {
 	}
 }
 
+// Release implements common.Releasable.Release().
 func (v *BufferedWriter) Release() {
-	v.Flush()
-
-	v.buffer.Release()
-	v.buffer = nil
+	if !v.buffer.IsEmpty() {
+		v.Flush()
+	}
 
+	if v.buffer != nil {
+		v.buffer.Release()
+		v.buffer = nil
+	}
 	common.Release(v.writer)
 }