[MPlayer-dev-eng] [PATCH] vf_delogo: variable rectangle

Nicolas George nicolas.george at normalesup.org
Wed Mar 16 19:49:57 CET 2011


Le duodi 22 pluviôse, an CCXIX, Reimar Döffinger a écrit :
> if (alloc_rect > INT_MAX / sizeof(*rect))
> 
> Always keep the value you need to validate on its own, otherwise
> it gets really difficult to make sure you didn't miss anything
> (in this case it also has the very minor advantage of not requiring
> a division at runtime, it can be calculated at compile-time).
> Since you always multiply by two other checks (like checking that
> previous_n * sizeof() < INT_MAX/2) are possible as well.

I did not find struct_realloc, but it does not take care of dying anyway.

Here is a new version that introduce *alloc functions that print an error
message and exit if they fail (keep in mind that most current OS overcommit
the memory, so the mallocs usually do not fail anyway). They could be more
widely used in the rest of the code.

> I always forget what exactly sscanf supports, but adding a \n or
> a space at the end should help catch some wrong formats e.g.
> when it ends with "12something"

Not so simple, sscanf would just stop parsing, and since there are no more
conversion, it does not report it. Anyway, it is not a serious problem to
parse "12something" as "12". In fact, it makes the parser support comments
there although it was not supposed to.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Introduce-mp_mem.-ch-for-memory-alloc-helpers.patch
Type: text/x-diff
Size: 4720 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20110316/9a40aa94/attachment-0002.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-vf_delogo-allow-to-change-the-rectangle-based-on-the.patch
Type: text/x-diff
Size: 7522 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20110316/9a40aa94/attachment-0003.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20110316/9a40aa94/attachment-0001.pgp>


More information about the MPlayer-dev-eng mailing list