fuzzers: wait for file start event before idle

Sometimes we exited too soon, not waiting for full transition to idle
state.
This commit is contained in:
Kacper Michajłow 2024-06-26 23:12:42 +02:00
parent 995283bd7a
commit 4574644b7a
3 changed files with 15 additions and 6 deletions

View File

@ -81,9 +81,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
check_error(mpv_command(ctx, cmd));
#ifdef MPV_LOADFILE
bool loaded = false;
while (1) {
mpv_event *event = mpv_wait_event(ctx, 10000);
if (event->event_id == MPV_EVENT_IDLE)
mpv_event *event = mpv_wait_event(ctx, -1);
if (event->event_id == MPV_EVENT_START_FILE)
loaded = true;
if (loaded && event->event_id == MPV_EVENT_IDLE)
break;
}
#endif

View File

@ -75,9 +75,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
const char *cmd[] = {"loadfile", data, NULL};
check_error(mpv_command(ctx, cmd));
bool loaded = false;
while (1) {
mpv_event *event = mpv_wait_event(ctx, 10000);
if (event->event_id == MPV_EVENT_IDLE)
mpv_event *event = mpv_wait_event(ctx, -1);
if (event->event_id == MPV_EVENT_START_FILE)
loaded = true;
if (loaded && event->event_id == MPV_EVENT_IDLE)
break;
}

View File

@ -104,9 +104,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
const char *cmd[] = {"loadfile", "av://lavfi:yuvtestsrc=d=0.01", NULL};
check_error(mpv_command(ctx, cmd));
bool loaded = false;
while (1) {
mpv_event *event = mpv_wait_event(ctx, 10000);
if (event->event_id == MPV_EVENT_IDLE)
mpv_event *event = mpv_wait_event(ctx, -1);
if (event->event_id == MPV_EVENT_START_FILE)
loaded = true;
if (loaded && event->event_id == MPV_EVENT_IDLE)
break;
}
#endif