projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
425d780
)
i18n: Avoid memory leak when create_iconv() fails.
author
Ben Pfaff
<blp@cs.stanford.edu>
Tue, 21 Sep 2010 04:50:21 +0000
(21:50 -0700)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Wed, 22 Sep 2010 05:11:14 +0000
(22:11 -0700)
src/libpspp/i18n.c
patch
|
blob
|
history
diff --git
a/src/libpspp/i18n.c
b/src/libpspp/i18n.c
index eb082c5d94b4f9bc0f798f8f0bf0c17e095d8a81..3735e95d8438821e6b338641581836f83dc7da7c 100644
(file)
--- 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;
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;
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;
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,
do {
const char *ip = text;
result = iconv (conv, (ICONV_CONST char **) &text, &inbytes,