[MPlayer-dev-eng] [PATCH] Subtitles directories

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Nov 21 12:24:32 CET 2010


On Sun, Nov 21, 2010 at 12:05:58PM +0100, Clément Bœsch wrote:
> +static void append_sub(struct sub_list *dst, struct subfn *src)

I suspect you are lucky here and a check outside that function saves you.
However

> +    dst->size = dst->sid + src->sid;

Possibly integer overflow.

> +    dst->subs = realloc(dst->subs, sizeof(*dst->subs) * dst->size);

Possible integer overflow.
Also realloc failure is not handled.

> +        struct sub_list tmp_list = get_sub_list(mp_subdir, fname);
> +        merge_subs(&fslist, &tmp_list);

You always call first get_sub_list and then merge_subs,
why not just append them to the proper list in the
first place in get_sub_list?
Also I'd be strongly in favour of limiting the number of
overall subs, not just per directory, then you can just
avoid all that realloc and overflow checking mess and
allocate a array with max size from the start.


More information about the MPlayer-dev-eng mailing list