[Ffmpeg-devel] [PATCH] from DivX, Part 1: cosmectic changes
Michael Niedermayer
michaelni
Sat Dec 17 02:06:00 CET 2005
Hi
On Fri, Dec 16, 2005 at 09:37:02PM +0000, M?ns Rullg?rd wrote:
> Steve Lhomme <slhomme at divxcorp.com> writes:
>
> >>>>@@ -713,8 +713,8 @@
> >>>> else
> >>>> io_buffer_size = 1024;
> >>>> - if(sizeof(DynBuffer) + io_buffer_size < io_buffer_size)
> >>>>- return -1;
> >>>>+ assert(sizeof(DynBuffer) + io_buffer_size >= io_buffer_size);
> >>>>+
> >>>>
> >>>>
> >>>
> >>>?
> >> such changes are not acceptable
> >
> > Ah. But this one is the most interresting patch.
> >
> > Because if you look at the original code. I can't think of any case
> > where this is true. So I'd better remove it of my Release (no assert)
> > builds.
>
> The type of a sizeof() expression is size_t, which is unsigned. Hence
> sizeof(foo) + x < x is impossible, unless the addition overflows.
yes, maybe looking at the next line clarifies the meaning behind this
d = av_malloc(sizeof(DynBuffer) + io_buffer_size);
if it overflows, you will have a too small buffer ...
[...]
--
Michael
More information about the ffmpeg-devel
mailing list