[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[i18n 2/6] i18n: Avoid memory leak when create_iconv() fails.
From: |
Ben Pfaff |
Subject: |
[i18n 2/6] i18n: Avoid memory leak when create_iconv() fails. |
Date: |
Mon, 20 Sep 2010 22:50:22 -0700 |
---
src/libpspp/i18n.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c
index eb082c5..3735e95 100644
--- a/src/libpspp/i18n.c
+++ b/src/libpspp/i18n.c
@@ -137,6 +137,11 @@ recode_string_pool (const char *to, const char *from,
if (from == NULL)
from = default_encoding;
+ conv = create_iconv (to, from);
+
+ if ( (iconv_t) -1 == conv )
+ return xstrdup (text);
+
for ( outbufferlength = 1 ; outbufferlength != 0; outbufferlength <<= 1 )
if ( outbufferlength > length)
break;
@@ -148,11 +153,6 @@ recode_string_pool (const char *to, const char *from,
inbytes = length;
- conv = create_iconv (to, from);
-
- if ( (iconv_t) -1 == conv )
- return xstrdup (text);
-
do {
const char *ip = text;
result = iconv (conv, (ICONV_CONST char **) &text, &inbytes,
--
1.7.1
- [i18n 0/6] Fixes for recode_string()., Ben Pfaff, 2010/09/21
- [i18n 3/6] i18n: Ensure that every recoding starts from the initial shift state., Ben Pfaff, 2010/09/21
- [i18n 4/6] i18n: Properly restart conversion when output buffer overflows., Ben Pfaff, 2010/09/21
- [i18n 5/6] i18n: Refactor for simplicity., Ben Pfaff, 2010/09/21
- [i18n 1/6] i18n: Lightly reformat comments to better resemble other files., Ben Pfaff, 2010/09/21
- [i18n 6/6] i18n: Handle EINVAL more gracefully., Ben Pfaff, 2010/09/21
- [i18n 2/6] i18n: Avoid memory leak when create_iconv() fails.,
Ben Pfaff <=
- Re: [i18n 0/6] Fixes for recode_string()., John Darrington, 2010/09/21