Fix segfault on OSX when destructor called
diff --git a/src/main/cpp/logstream.cpp b/src/main/cpp/logstream.cpp
index de9a763..29c3bcf 100644
--- a/src/main/cpp/logstream.cpp
+++ b/src/main/cpp/logstream.cpp
@@ -35,6 +35,9 @@
//
memset(this, 0, sizeof(*this));
#endif
+#if LOG4CXX_INIT_IOS_BASE
+ init(NULL);
+#endif
flags(initval);
precision(initsize);
width(initsize);
diff --git a/src/main/include/CMakeLists.txt b/src/main/include/CMakeLists.txt
index d1a0bb2..a8b0f40 100644
--- a/src/main/include/CMakeLists.txt
+++ b/src/main/include/CMakeLists.txt
@@ -34,8 +34,10 @@
endif()
option(LOG4CXX_WCHAR_T "Enable wchar_t API methods" ON)
option(LOG4CXX_UNICHAR "Enable UniChar API methods" OFF)
+set(INIT_IOS_BASE 0)
if(APPLE)
option(LOG4CXX_CFSTRING "Enable CFString API methods, requires Mac OS/X CoreFoundation" OFF)
+set(INIT_IOS_BASE 1)
endif()
set(CHAR_API 1)
foreach(varName WCHAR_T UNICHAR CFSTRING )
diff --git a/src/main/include/log4cxx/private/log4cxx_private.h.in b/src/main/include/log4cxx/private/log4cxx_private.h.in
index e21f4d8..53e59ef 100644
--- a/src/main/include/log4cxx/private/log4cxx_private.h.in
+++ b/src/main/include/log4cxx/private/log4cxx_private.h.in
@@ -40,6 +40,7 @@
#define LOG4CXX_HAS_MBSRTOWCS @HAS_MBSRTOWCS@
#define LOG4CXX_HAS_WCSTOMBS @HAS_WCSTOMBS@
#define LOG4CXX_HAS_FWIDE @HAS_FWIDE@
+#define LOG4CXX_INIT_IOS_BASE @INIT_IOS_BASE@
#define LOG4CXX_CHARSET_UTF8 @CHARSET_UTF8@
#define LOG4CXX_CHARSET_ISO88591 @CHARSET_ISO88591@