diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Revision history for hpath-posix
 
+## 0.13.2 -- 2020-04-14
+
+* fix macOS compatibility, especially with memory bug in `fdopendir`
+
 ## 0.13.1 -- 2020-02-08
 
 * Remove unnecessary dependencies
diff --git a/cbits/dirutils.c b/cbits/dirutils.c
--- a/cbits/dirutils.c
+++ b/cbits/dirutils.c
@@ -1,7 +1,7 @@
 #include "dirutils.h"
+
 unsigned int
     __posixdir_d_type(struct dirent* d)
     {
       return(d -> d_type);
     }
-
diff --git a/cbits/dirutils.h b/cbits/dirutils.h
--- a/cbits/dirutils.h
+++ b/cbits/dirutils.h
@@ -7,7 +7,9 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
+
 extern unsigned int
     __posixdir_d_type(struct dirent* d)
     ;
+
 #endif
diff --git a/hpath-posix.cabal b/hpath-posix.cabal
--- a/hpath-posix.cabal
+++ b/hpath-posix.cabal
@@ -1,7 +1,7 @@
 cabal-version:       >=1.10
 
 name:                hpath-posix
-version:             0.13.1
+version:             0.13.2
 synopsis:            Some low-level POSIX glue code, that is not in 'unix'
 homepage:            https://github.com/hasufell/hpath
 bug-reports:         https://github.com/hasufell/hpath/issues
diff --git a/src/System/Posix/RawFilePath/Directory/Traversals.hs b/src/System/Posix/RawFilePath/Directory/Traversals.hs
--- a/src/System/Posix/RawFilePath/Directory/Traversals.hs
+++ b/src/System/Posix/RawFilePath/Directory/Traversals.hs
@@ -10,6 +10,7 @@
 -- Traversal and read operations on directories.
 
 
+{-# LANGUAGE CApiFFI #-}
 {-# LANGUAGE CPP #-}
 {-# LANGUAGE ForeignFunctionInterface #-}
 {-# LANGUAGE OverloadedStrings #-}
@@ -173,11 +174,15 @@
 foreign import ccall unsafe "__posixdir_d_type"
   c_type :: Ptr CDirent -> IO DirType
 
-foreign import ccall "realpath"
+foreign import capi "stdlib.h realpath"
   c_realpath :: CString -> CString -> IO CString
 
-foreign import ccall unsafe "fdopendir"
-  c_fdopendir :: Posix.Fd -> IO (Ptr ())
+-- Using normal 'ccall' here lead to memory bugs, crashes
+-- and corrupted d_name entries. It appears there are two fdopendirs:
+--   https://opensource.apple.com/source/Libc/Libc-1244.1.7/include/dirent.h.auto.html
+-- The capi call picks the correct one.
+foreign import capi unsafe "dirent.h fdopendir"
+  c_fdopendir :: Posix.Fd -> IO (Ptr CDir)
 
 ----------------------------------------------------------
 -- less dodgy but still lower-level
