Janne Grunau <[email protected]> writes: > On 2012-02-01 14:14:40 +0000, Måns Rullgård wrote: >> Janne Grunau <[email protected]> writes: > > [...] > >> > +void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) >> > +{ >> > + uint8_t **p = ptr; >> > + if (min_size > SIZE_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { >> > + *p = NULL; >> > + *size = 0; >> > + return; >> > + } >> > + av_fast_malloc(ptr, size, min_size + FF_INPUT_BUFFER_PADDING_SIZE); >> > + if (*p) >> > + memset(*p + min_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); >> > +} >> >> There might be a strict aliasing problem writing the pointer as void* >> (in av_fast_malloc) and reading it as uint8_t*. > > I'm not sure either but nothing prevents us from using p for > av_fast_malloc().
Only the fact that it makes no difference at all. Only the types of the lvalues in the write and subsequent read matter. Intermediate pointer types used are irrelevant. Declaring p as void**, then doing (uint8_t*)*p + min_size would be safe. -- Måns Rullgård [email protected] _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
