summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2004-02-09 12:42:55 +0000
committerDaniel Veillard <veillard@src.gnome.org>2004-02-09 12:42:55 +0000
commit182d32a53733b28ffe3caaa0ab53cda9f9b8522c (patch)
tree9f5b7f8fd90a78efa0f08e6da1ac3da823da06f7 /encoding.c
parent5bb9ccd56a812b65e94e71477389be7826203649 (diff)
downloadlibxml2-182d32a53733b28ffe3caaa0ab53cda9f9b8522c.tar.gz
applied a small patch from Alfred Mickautsch to avoid an out of bound
* encoding.c: applied a small patch from Alfred Mickautsch to avoid an out of bound error in isolat1ToUTF8() Daniel
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/encoding.c b/encoding.c
index 928f3afa..7ee072e4 100644
--- a/encoding.c
+++ b/encoding.c
@@ -235,28 +235,23 @@ isolat1ToUTF8(unsigned char* out, int *outlen,
unsigned char* outend = out + *outlen;
const unsigned char* inend;
const unsigned char* instop;
- xmlChar c = *in;
inend = in + (*inlen);
instop = inend;
while (in < inend && out < outend - 1) {
- if (c >= 0x80) {
- *out++= ((c >> 6) & 0x1F) | 0xC0;
- *out++= (c & 0x3F) | 0x80;
+ if (*in >= 0x80) {
+ *out++ = (((*in) >> 6) & 0x1F) | 0xC0;
+ *out++ = ((*in) & 0x3F) | 0x80;
++in;
- c = *in;
}
if (instop - in > outend - out) instop = in + (outend - out);
- while (c < 0x80 && in < instop) {
- *out++ = c;
- ++in;
- c = *in;
+ while (in < instop && *in < 0x80) {
+ *out++ = *in++;
}
}
- if (in < inend && out < outend && c < 0x80) {
- *out++ = c;
- ++in;
+ if (in < inend && out < outend && *in < 0x80) {
+ *out++ = *in++;
}
*outlen = out - outstart;
*inlen = in - base;