aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorThierry Crozat2019-09-30 22:02:05 +0100
committerThierry Crozat2019-09-30 22:04:27 +0100
commit06acfd515f2e210b8f0b0e628b107db785fcd692 (patch)
treed24eb9ffd459f876b696bf76e59710645a925535 /common
parent8ff5014526691f05741853fd18971c299e9912c4 (diff)
downloadscummvm-rg350-06acfd515f2e210b8f0b0e628b107db785fcd692.tar.gz
scummvm-rg350-06acfd515f2e210b8f0b0e628b107db785fcd692.tar.bz2
scummvm-rg350-06acfd515f2e210b8f0b0e628b107db785fcd692.zip
COMMON: Fix memory leaks in iconv error case
This fixes coverity CID 1405783 and CID 1405784.
Diffstat (limited to 'common')
-rw-r--r--common/encoding.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/common/encoding.cpp b/common/encoding.cpp
index 3c70f19334..46faebe313 100644
--- a/common/encoding.cpp
+++ b/common/encoding.cpp
@@ -197,6 +197,10 @@ char *Encoding::convertIconv(const char *to, const char *from, const char *strin
char *buffer = (char *) calloc(sizeof(char), stringSize);
if (!buffer) {
+#ifndef ICONV_USES_CONST
+ delete[] originalSrc;
+#endif // ICONV_USES_CONST
+ iconv_close(iconvHandle);
warning ("Cannot allocate memory for converting string");
return nullptr;
}