diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-27 18:52:41 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-27 18:52:41 +0000 |
commit | da5d2a2d0821241ea71f45b1e0faf627da1caf90 (patch) | |
tree | b57e81ff29decf59b313153db7ab43dc61fc2ffe /plugins | |
parent | 09cace2f7d8fdbfb047eba9a6396d79d59422443 (diff) |
memory leak fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@13861 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/MirOTR/src/entities.cpp | 18 | ||||
-rw-r--r-- | plugins/MirOTR/src/svcs_proto.cpp | 2 |
2 files changed, 12 insertions, 8 deletions
diff --git a/plugins/MirOTR/src/entities.cpp b/plugins/MirOTR/src/entities.cpp index 87cc198eaa..916bebd608 100644 --- a/plugins/MirOTR/src/entities.cpp +++ b/plugins/MirOTR/src/entities.cpp @@ -391,10 +391,14 @@ size_t decode_html_entities_utf8(char *dest, const char *src, size_t len) return (size_t)(to - dest); } -char * encode_html_entities_utf8(const char *src) { - const char *pos, *start=src; +char* encode_html_entities_utf8(const char *src) +{ + const char *pos = strpbrk(src, "&<>\"\r"); + if (!pos) + return NULL; + + const char *start = src; std::string buf; - if (! (pos = strpbrk(start, "&<>\"\r")) ) return NULL; while (pos) { buf.append(start, pos-start); start = pos+1; @@ -417,8 +421,8 @@ char * encode_html_entities_utf8(const char *src) { } pos = strpbrk(start, "&<>\"\r"); } - if (mir_strlen(start)) buf.append(start); - pos = mir_strdup(buf.c_str()); - buf.clear(); - return (char*)pos; + if (mir_strlen(start)) + buf.append(start); + + return mir_strndup(buf.c_str(), buf.size()); }
\ No newline at end of file diff --git a/plugins/MirOTR/src/svcs_proto.cpp b/plugins/MirOTR/src/svcs_proto.cpp index bb88823c04..637497350a 100644 --- a/plugins/MirOTR/src/svcs_proto.cpp +++ b/plugins/MirOTR/src/svcs_proto.cpp @@ -30,7 +30,7 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ return CallService(MS_PROTO_CHAINSEND, wParam, lParam); } - char *tmpencode = NULL; + ptrA tmpencode; ConnContext *context = otrl_context_find_miranda(otr_user_state, ccs->hContact); if (db_get_b(ccs->hContact, MODULENAME, "HTMLConv", 0) && otr_context_get_trust(context) >= TRUST_UNVERIFIED) { tmpencode = encode_html_entities_utf8(oldmessage); |