Skip to content

Commit 9d995dd

Browse files
committed
Fix usage problems with iconv
iconv_close() wasn't always being called. iconv's buffer wasn't being reset when there was nothing to convert
1 parent 791a9d2 commit 9d995dd

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Changelog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Version Changes for Hypermail
44
HYPERMAIL VERSION 2.4.0:
55
============================
66

7+
2018-11-04 Bill Shannon
8+
* string.c
9+
i18n_convstring(): fix usage problems with iconv
10+
711
2018-10-12 Jose Kahan
812
* setup.c
913
PreConfig(): removed a 64-bit warning

src/string.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ char *i18n_convstring(char *string, char *fromcharset, char *tocharset, size_t *
287287
}
288288
errno=0;
289289
ret=iconv(iconvfd, &string, &strleft, &convbuf, &bufleft);
290-
iconv_close(iconvfd);
291290

292291
if (ret==(size_t)-1){
293292
error = 1;
@@ -315,8 +314,11 @@ char *i18n_convstring(char *string, char *fromcharset, char *tocharset, size_t *
315314
break;
316315
}
317316
} else {
317+
/* return to initial state */
318+
iconv(iconvfd, NULL, NULL, &convbuf, &bufleft);
318319
error = 0;
319320
}
321+
iconv_close(iconvfd);
320322

321323
if (error) {
322324
origconvbuf[origlen]=0x0;

0 commit comments

Comments
 (0)