[m-rev.] diff: fix segmentation fault in runtime on Mac OS X

Julien Fischer jfischer at opturion.com
Thu Jun 26 13:05:47 AEST 2014


Branches: master, 14.01

Fix a segmentation fault in the runtime on Mac OS X.

runtime/mercury_runtime_util.c:
 	On Mac OS X, strerror_r also does not populate its buffer
 	if it fails.

Julien.

diff --git a/runtime/mercury_runtime_util.c b/runtime/mercury_runtime_util.c
index e9cfd88..8fe1fa0 100644
--- a/runtime/mercury_runtime_util.c
+++ b/runtime/mercury_runtime_util.c
@@ -55,10 +55,11 @@ MR_strerror(int errnum, char *buf, size_t buflen)
      return buf;
  #elif defined(MR_HAVE_STRERROR_R)
      /*
-    ** The XSI-compliant strerror_r populates buf unless it fails.
+    ** The XSI-compliant and Mac OS X strerror_r populates buf unless it fails.
      ** The GNU-specific strerror_r does not always populate buf.
      */
-  #if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
+  #if defined(MR_MAC_OSX) || \
+       ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE)
      if (strerror_r(errnum, buf, buflen) != 0) {
          generic_strerror(errnum, buf, buflen);
      }



More information about the reviews mailing list