#50 bug in string parsing

open
nobody
None
5
2007-09-27
2007-09-27
Anonymous
No

In using xlhtml I found a bug in the parsing of strings:

During a 0xFC (Packed string) command if we encounter a 0x3C (continue) command, and if we were in the middle of a string, the 0x3C will be followed by 2 bytes for the length and 1 byte for the string encoding. This last byte allows for a change of encoding in the middle of the string i.e.:
1-switch from Unicode to ASCII
2-switch from ASCII to unicode

case 1- is handled properly but case 2- is not handled.
I wrote a quick fix:

if ((count == 0)&&(cont_opcode == 1)&&(buflast))
{
cont_str_array = 1;
cont_grbit = data;
/* bug fix start */
if (!(grbit&1) && (cont_grbit&1)) {
buflast*=2;
bufidx*=2;
for (int i=bufidx-1; i>=0; i--) {
if (i&1)
working_buffer[i] = 0;
else
working_buffer[i] = working_buffer[i/2];
}
grbit |= 1;
}
/* bug fix end */
return;
}

Thanks for writing this in the first place. It is very usefull.

Brice Rive (bricerive at free.fr)

Discussion


Log in to post a comment.