summaryrefslogtreecommitdiffstats
path: root/libcxx/src/ios.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/src/ios.cpp')
-rw-r--r--libcxx/src/ios.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libcxx/src/ios.cpp b/libcxx/src/ios.cpp
index d58827fa1255..a727855c4655 100644
--- a/libcxx/src/ios.cpp
+++ b/libcxx/src/ios.cpp
@@ -195,6 +195,10 @@ void ios_base::register_callback(event_callback fn, int index) {
}
ios_base::~ios_base() {
+ // Avoid UB when not properly initialized. See ios_base::ios_base for
+ // more information.
+ if (!__loc_)
+ return;
__call_callbacks(erase_event);
locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
loc_storage.~locale();