about summary refs log tree commit diff
path: root/src/locale/iconv.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-06-18 20:43:21 -0400
committerRich Felker <dalias@aerifal.cx>2012-06-18 20:43:21 -0400
commit673633c689989c5cb7ba0b919f8ef82c4041e2ec (patch)
tree600d045e98f4ace3e7efff9fcfc275173805a5b4 /src/locale/iconv.c
parenta2f149b5d183a842487cc7c76d63511b67db32f5 (diff)
downloadmusl-673633c689989c5cb7ba0b919f8ef82c4041e2ec.tar.gz
musl-673633c689989c5cb7ba0b919f8ef82c4041e2ec.tar.xz
musl-673633c689989c5cb7ba0b919f8ef82c4041e2ec.zip
fix iconv dest utf-16: unavailable chars must be replaced; EILSEQ is wrong
Diffstat (limited to 'src/locale/iconv.c')
-rw-r--r--src/locale/iconv.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/locale/iconv.c b/src/locale/iconv.c
index c48e45aa..78c215e1 100644
--- a/src/locale/iconv.c
+++ b/src/locale/iconv.c
@@ -327,14 +327,14 @@ size_t iconv(iconv_t cd0, char **in, size_t *inb, char **out, size_t *outb)
 		case UCS2LE:
 		case UTF_16BE:
 		case UTF_16LE:
-			if (c < 0x10000) {
+			if (c < 0x10000 || type-UCS2BE < 2U) {
+				if (c >= 0x10000) c = 0xFFFD;
 				if (*outb < 2) goto toobig;
 				put_16((void *)*out, c, totype);
 				*out += 2;
 				*outb -= 2;
 				break;
 			}
-			if (type-UCS2BE < 2U) goto ilseq;
 			if (*outb < 4) goto toobig;
 			c -= 0x10000;
 			put_16((void *)*out, (c>>10)|0xd800, totype);