for(i=0; i < n; i+=2)
{
unsigned long point = ((unsigned long) s[i+high]<<8) + s[i+low];
- if((point & 0xd800) == 0xd800) /* lead surrogate */
+ if((point & 0xfc00) == 0xd800) /* lead surrogate */
{
unsigned short second = (i+3 < l) ? (s[i+2+high]<<8) + s[i+2+low] : 0;
- if((second & 0xdc00) == 0xdc00) /* good... */
+ if((second & 0xfc00) == 0xdc00) /* good... */
{
point = FULLPOINT(point,second);
length += UTF8LEN(point); /* possibly 4 bytes */
for(i=0; i < n; i+=2)
{
unsigned long codepoint = ((unsigned long) s[i+high]<<8) + s[i+low];
- if((codepoint & 0xd800) == 0xd800) /* lead surrogate */
+ if((codepoint & 0xfc00) == 0xd800) /* lead surrogate */
{
unsigned short second = (s[i+2+high]<<8) + s[i+2+low];
codepoint = FULLPOINT(codepoint,second);
* <0: error codes, possibly from feeder buffer (NEED_MORE)
* PARSE_BAD: cannot get the framesize for some reason and shall silentry try the next possible header (if this is no free format stream after all...)
*/
-static int guess_freeformat_framesize(mpg123_handle *fr)
+static int guess_freeformat_framesize(mpg123_handle *fr, unsigned long oldhead)
{
long i;
int ret;
if((ret=fr->rd->head_shift(fr,&head))<=0) return ret;
/* No head_check needed, the mask contains all relevant bits. */
- if((head & HDR_SAMEMASK) == (fr->oldhead & HDR_SAMEMASK))
+ if((head & HDR_SAMEMASK) == (oldhead & HDR_SAMEMASK))
{
fr->rd->back_bytes(fr,i+1);
fr->framesize = i-3;
if(VERBOSE3) error("You fooled me too often. Refusing to guess free format frame size _again_.");
return PARSE_BAD;
}
- ret = guess_freeformat_framesize(fr);
+ ret = guess_freeformat_framesize(fr, newhead);
if(ret == PARSE_GOOD)
{
fr->freeformat_framesize = fr->framesize - fr->padding;