diff --git a/Graphics/X11/Xrandr.hsc b/Graphics/X11/Xrandr.hsc index 3d17dbf..3075f28 100644 --- a/Graphics/X11/Xrandr.hsc +++ b/Graphics/X11/Xrandr.hsc @@ -418,7 +418,6 @@ xrrConfigSizes config = sizes <- if nsizes == 0 then return Nothing else peekArray (fromIntegral nsizes) p >>= return . Just - _ <- xFree p return sizes foreign import ccall "XRRConfigSizes" cXRRConfigSizes :: XRRScreenConfiguration -> Ptr CInt -> IO (Ptr XRRScreenSize) @@ -433,7 +432,6 @@ xrrConfigRates config size_index = rates <- if nrates == 0 then return Nothing else peekArray (fromIntegral nrates) p >>= return . Just - _ <- xFree p return rates foreign import ccall "XRRConfigRates" cXRRConfigRates :: XRRScreenConfiguration -> CInt -> Ptr CInt -> IO (Ptr CShort) @@ -486,7 +484,6 @@ xrrSizes dpy screen = sizes <- if nsizes == 0 then return Nothing else peekArray (fromIntegral nsizes) p >>= return . Just - _ <- xFree p return sizes foreign import ccall "XRRSizes" cXRRSizes :: Display -> CInt -> Ptr CInt -> IO (Ptr XRRScreenSize) @@ -501,7 +498,6 @@ xrrRates dpy screen size_index = rates <- if nrates == 0 then return Nothing else peekArray (fromIntegral nrates) p >>= return . Just - _ <- xFree p return rates foreign import ccall "XRRRates" cXRRRates :: Display -> CInt -> CInt -> Ptr CInt -> IO (Ptr CShort) @@ -680,7 +676,9 @@ xrrGetOutputProperty dpy rro prop offset len delete preferPending reqType = with 32 -> peekArray nitems (castPtr ptr :: Ptr Word32) _ -> error $ "impossible happened: prop format is not in 0,8,16,32 (" ++ show format ++ ")" - _ <- xFree ptr + _ <- if format /= 0 + then xFree ptr + else return 0 typ <- peek actualTypep bytesAfter <- peek bytesAfterp