diff options
| author | wangmenglan <[email protected]> | 2023-05-22 15:19:29 +0800 |
|---|---|---|
| committer | wangmenglan <[email protected]> | 2023-05-22 15:19:29 +0800 |
| commit | fc2625c691cd1a12a78c93b762028414ade0b088 (patch) | |
| tree | ba155bc98c3a1e17d1d85e96de41d7cc41327f9f /common/src/tfe_ctrl_packet.cpp | |
| parent | b931a3dc58dead4e02cda48813bdffd2e2d072c0 (diff) | |
bugfix:修复packet io内存泄漏v4.8.13-20230522
Diffstat (limited to 'common/src/tfe_ctrl_packet.cpp')
| -rw-r--r-- | common/src/tfe_ctrl_packet.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/common/src/tfe_ctrl_packet.cpp b/common/src/tfe_ctrl_packet.cpp index c535857..206eb96 100644 --- a/common/src/tfe_ctrl_packet.cpp +++ b/common/src/tfe_ctrl_packet.cpp @@ -297,6 +297,8 @@ int ctrl_packet_parser_parse(void *ctx, const char* data, size_t length, void *l goto error; } + handler->cmsg = tfe_cmsg_init(); + tfe_cmsg_dup(handler->cmsg); proxy_map = mpack_node_map_cstr(params, "proxy"); ret = proxy_parse_messagepack(proxy_map, handler, logger); if (ret != 0) @@ -307,6 +309,8 @@ succ: return 0; error: mpack_tree_destroy(&tree); + tfe_cmsg_destroy(handler->cmsg); + tfe_cmsg_destroy(handler->cmsg); return -1; } @@ -330,8 +334,14 @@ const char *session_state_to_string(enum session_state state) void ctrl_packet_parser_init(struct ctrl_pkt_parser *handler) { memset(handler, 0, sizeof(struct ctrl_pkt_parser)); - handler->cmsg = tfe_cmsg_init(); - tfe_cmsg_dup(handler->cmsg); +} + +void ctrl_packet_cmsg_destroy(struct ctrl_pkt_parser *handler) +{ + if (handler) { + tfe_cmsg_destroy(handler->cmsg); + tfe_cmsg_destroy(handler->cmsg); + } } void ctrl_packet_parser_dump(struct ctrl_pkt_parser *handler, void *logger) |
