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/MirOTR/src/entities.cpp | |
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/MirOTR/src/entities.cpp')
-rw-r--r-- | plugins/MirOTR/src/entities.cpp | 18 |
1 files changed, 11 insertions, 7 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 |