summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/openssl.c8
-rw-r--r--test/testutil/init.c8
2 files changed, 14 insertions, 2 deletions
diff --git a/apps/openssl.c b/apps/openssl.c
index 9c0d933d7b..7a490cc455 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -216,6 +216,13 @@ static void setup_trace(const char *str)
{
char *val;
+ /*
+ * We add this handler as early as possible to ensure it's executed
+ * as late as possible, i.e. after the TRACE code has done its cleanup
+ * (which happens last in OPENSSL_cleanup).
+ */
+ atexit(cleanup_trace);
+
trace_data_stack = sk_tracedata_new_null();
val = OPENSSL_strdup(str);
@@ -240,7 +247,6 @@ static void setup_trace(const char *str)
}
OPENSSL_free(val);
- atexit(cleanup_trace);
}
#endif /* OPENSSL_NO_TRACE */
diff --git a/test/testutil/init.c b/test/testutil/init.c
index b4a7277f02..429c1a0333 100644
--- a/test/testutil/init.c
+++ b/test/testutil/init.c
@@ -102,6 +102,13 @@ static void setup_trace(const char *str)
{
char *val;
+ /*
+ * We add this handler as early as possible to ensure it's executed
+ * as late as possible, i.e. after the TRACE code has done its cleanup
+ * (which happens last in OPENSSL_cleanup).
+ */
+ atexit(cleanup_trace);
+
trace_data_stack = sk_tracedata_new_null();
val = OPENSSL_strdup(str);
@@ -126,7 +133,6 @@ static void setup_trace(const char *str)
}
OPENSSL_free(val);
- atexit(cleanup_trace);
}
#endif /* OPENSSL_NO_TRACE */