[x264-devel] Crash due to unaligned pointer on SPARC

Jason Garrett-Glaser darkshikari at gmail.com
Tue Feb 3 01:26:11 CET 2009


> Thanks for your reply, but I am unable to determine to which patch you are
> referring. Has it been committed?

It seems the message was only sent to me and a few others, not to the
ML.  Here it is.

Dark Shikari

Hello,
the bs_init function has two bugs for non aligned  p_data pointer.

I suggest to replace
  s->i_left  = offset ? 8*offset : (WORD_SIZE*8);
 s->cur_bits = endian_fix( *(intptr_t*)s->p );
by
 s->i_left  = (WORD_SIZE - offset )*8;
 s->cur_bits = endian_fix( *(intptr_t*)s->p ) >> s->i_left;

Mehdi MOSTAFAVI


inline void bs_init( bs_t *s, void *p_data, int i_data )
{
  int offset = ((intptr_t)p_data & (WORD_SIZE-1));
  s->p       = s->p_start = (uint8_t*)p_data - offset;
  s->p_end   = (uint8_t*)p_data + i_data;
  s->i_left  = (WORD_SIZE - offset )*8;
  s->cur_bits = endian_fix( *(intptr_t*)s->p ) >> s->i_left;
}


More information about the x264-devel mailing list