ass: discard invalid events early
ass: discard invalid events early

They cannot possibly produce any rendering output,
so there's no benefit in keeping them around. On the
contrary, keeping them around can significantly slow down
processing of fuzzing samples as discovered by OSS-Fuzz.

For its sample, there's one valid event with a large Text entry
(516503 bytes) and 9786 invalid events.
Processing just the one valid events takes a few seconds, which
isn't fast but still bearable and given the large amount of text being
parsed, shaped and rendered not too surprising.
If now the invalid events are kept around, processing the sample still
wasn't finished after 5 minutes. While processing of invalid events ends
early in ass_render_event and they won't create any output themselves,
their time overlaps with the costly, valid event. Meaning this costly
event now get's rendered thousands of times and processing cost is
amplified via just a few bytes being added by the fuzzing engine.

We already do a similar discarding for Styles in process_style().
Unlike the former, process_event_tail() doesn't allocate the new
event itself, so discarding is instead done by its callers.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47952

astiob/libass,libass/libass,astiob/libass,libass/libass