From: Chris Rienzo Date: Thu, 7 Mar 2019 01:54:57 +0000 (-0500) Subject: FS-11691 [core] fix switch_log_node_dup() so that it completely duplicates log nodes X-Git-Tag: v1.8.6~1^2~101^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10f642249e13568d2e4412a4a4e962d1a8c900bf;p=thirdparty%2Ffreeswitch.git FS-11691 [core] fix switch_log_node_dup() so that it completely duplicates log nodes --- diff --git a/src/switch_log.c b/src/switch_log.c index 09c2b49df2..bed7b48968 100644 --- a/src/switch_log.c +++ b/src/switch_log.c @@ -108,15 +108,21 @@ SWITCH_DECLARE(switch_log_node_t *) switch_log_node_dup(const switch_log_node_t switch_log_node_t *newnode = switch_log_node_alloc(); *newnode = *node; + newnode->content = NULL; - if (!zstr(node->data)) { + if (node->data) { newnode->data = strdup(node->data); - switch_assert(node->data); + switch_assert(newnode->data); + + // content is a pointer inside data; need to calculate the new pointer + if (node->content && node->content >= node->data) { + newnode->content = newnode->data + (node->content - node->data); + } } - if (!zstr(node->userdata)) { + if (node->userdata) { newnode->userdata = strdup(node->userdata); - switch_assert(node->userdata); + switch_assert(newnode->userdata); } return newnode;