summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/trace.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/crypto/trace.c b/crypto/trace.c
index 520d2a5178..de03fe954c 100644
--- a/crypto/trace.c
+++ b/crypto/trace.c
@@ -287,11 +287,6 @@ static int set_trace_data(int category, int type, BIO **channel,
}
/* Before running callbacks are done, set new data where appropriate */
- if (channel != NULL && *channel != NULL) {
- trace_channels[category].type = type;
- trace_channels[category].bio = *channel;
- }
-
if (prefix != NULL && *prefix != NULL) {
if ((curr_prefix = OPENSSL_strdup(*prefix)) == NULL)
return 0;
@@ -304,6 +299,15 @@ static int set_trace_data(int category, int type, BIO **channel,
trace_channels[category].suffix = curr_suffix;
}
+ if (channel != NULL && *channel != NULL) {
+ trace_channels[category].type = type;
+ trace_channels[category].bio = *channel;
+ /*
+ * This must not be done before setting prefix/suffix,
+ * as those may fail, and then the caller is mislead to free *channel.
+ */
+ }
+
/* Finally, run the attach callback on the new data */
if (channel != NULL && *channel != NULL) {
attach_cb(category, CHANNEL, *channel);