[commit: packages/binary] master: Fix memory leak when decoding Float and Double. (497a181)

git at git.haskell.org git at git.haskell.org
Mon Jun 1 08:47:51 UTC 2015


Repository : ssh://git@git.haskell.org/binary

On branch  : master
Link       : http://git.haskell.org/packages/binary.git/commitdiff/497a181c083fa9faf7fa3aa64d1d8deb9ac76ecb

>---------------------------------------------------------------

commit 497a181c083fa9faf7fa3aa64d1d8deb9ac76ecb
Author: Lennart Kolmodin <kolmodin at google.com>
Date:   Sat May 30 16:14:03 2015 +0200

    Fix memory leak when decoding Float and Double.


>---------------------------------------------------------------

497a181c083fa9faf7fa3aa64d1d8deb9ac76ecb
 src/Data/Binary/Class.hs | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/Data/Binary/Class.hs b/src/Data/Binary/Class.hs
index 2477056..5aa6c05 100644
--- a/src/Data/Binary/Class.hs
+++ b/src/Data/Binary/Class.hs
@@ -537,11 +537,17 @@ instance (Binary e) => Binary (Seq.Seq e) where
 
 instance Binary Double where
     put d = put (decodeFloat d)
-    get   = liftM2 encodeFloat get get
+    get   = do
+        x <- get
+        y <- get
+        return $! encodeFloat x y
 
 instance Binary Float where
     put f = put (decodeFloat f)
-    get   = liftM2 encodeFloat get get
+    get   =  do
+        x <- get
+        y <- get
+        return $! encodeFloat x y
 
 ------------------------------------------------------------------------
 -- Trees



More information about the ghc-commits mailing list