[PATCH 1/3] Don't mangle errno with free(3) if utrace(2) fails

Garrett Cooper yanegomi at gmail.com
Sun Dec 2 17:56:25 PST 2012


This ensures POLA on FreeBSD (at least) as free(3) is generally assumed
to not fiddle around with errno.

Signed-off-by: Garrett Cooper <yanegomi at gmail.com>
---
  src/jemalloc.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/src/jemalloc.c b/src/jemalloc.c
index 8a667b6..ec3805c 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -83,11 +83,13 @@ typedef struct {
  #ifdef JEMALLOC_UTRACE
  #  define UTRACE(a, b, c) do {						\
  	if (opt_utrace) {						\
+		int utrace_serrno = errno;				\
  		malloc_utrace_t ut;					\
  		ut.p = (a);						\
  		ut.s = (b);						\
  		ut.r = (c);						\
  		utrace(&ut, sizeof(ut));				\
+		errno = utrace_serrno;					\
  	}								\
  } while (0)
  #else
-- 
1.8.0




More information about the jemalloc-discuss mailing list