X-Git-Url: http://developer.intra2net.com/git/?a=blobdiff_plain;f=src%2Fstringfunc.cpp;fp=src%2Fstringfunc.cpp;h=7108bc93cd2f18b6b994b72e3d57bacde197e2c9;hb=858cd10b4a51801e7639b146a9ca6bacda6bc273;hp=d611abf62fcf75578f998b764b8f7713ee708014;hpb=4b497d721ebe04fc39e6df337600509542bcbfe0;p=libi2ncommon diff --git a/src/stringfunc.cpp b/src/stringfunc.cpp index d611abf..7108bc9 100644 --- a/src/stringfunc.cpp +++ b/src/stringfunc.cpp @@ -795,7 +795,10 @@ std::string iso_to_utf8(const std::string& isostring) char *buf = (char *)malloc(out_size+1); if (buf == NULL) + { + iconv_close(i2utf8); throw runtime_error("out of memory for iconv buffer"); + } char *in = (char *)isostring.c_str(); char *out = buf; @@ -825,7 +828,10 @@ std::string utf8_to_iso(const std::string& utf8string) char *buf = (char *)malloc(out_size+1); if (buf == NULL) + { + iconv_close(utf82iso); throw runtime_error("out of memory for iconv buffer"); + } char *in = (char *)utf8string.c_str(); char *out = buf; @@ -853,7 +859,10 @@ wchar_t* utf8_to_wbuf(const std::string& utf8string) wchar_t *buf = (wchar_t *)malloc(out_size); if (buf == NULL) + { + iconv_close(utf82wstr); throw runtime_error("out of memory for iconv buffer"); + } char *in = (char *)utf8string.c_str(); char *out = (char*) buf; @@ -881,7 +890,10 @@ std::string utf7imap_to_utf8(const std::string& utf7imapstring) char *buf = (char *)malloc(out_size+1); if (buf == NULL) + { + iconv_close(utf7imap2utf8); throw runtime_error("out of memory for iconv buffer"); + } char *in = (char *)utf7imapstring.c_str(); char *out = buf; @@ -913,7 +925,10 @@ std::string utf8_to_utf7imap(const std::string& utf8string) char *buf = (char *)malloc(out_size+1); if (buf == NULL) + { + iconv_close(utf82utf7imap); throw runtime_error("out of memory for iconv buffer"); + } char *in = (char *)utf8string.c_str(); char *out = buf;