From 730bae4a2d2579b862a34c6436d1652823899b90 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 4 Jul 2019 09:04:56 +0200 Subject: [PATCH] ogg_afh_common.c: Check return value of ogg_page_granulepos(). This function may return -1, and we do not want to use a negative granule position for the computation of the duration of the ogg file. Note that oac_get_file_info() loops over all ogg pages twice, but the second loop does not have the same problem as we already check the return value there. --- ogg_afh_common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ogg_afh_common.c b/ogg_afh_common.c index 12a15206..3e36bdd5 100644 --- a/ogg_afh_common.c +++ b/ogg_afh_common.c @@ -148,8 +148,9 @@ int oac_get_file_info(char *map, size_t numbytes, struct afh_info *afhi, /* count ogg pages and get duration of the file */ for (i = 0; ogg_sync_pageseek(&oss, &op) > 0; i++) { int this_pageno = ogg_page_pageno(&op); - - granule = ogg_page_granulepos(&op); + int64_t this_granule = ogg_page_granulepos(&op); + if (this_granule >= 0) + granule = this_granule; if (i > 0 && this_pageno != prev_pageno + 1) /* hole */ granule_skip += granule - prev_granule; prev_pageno = this_pageno; -- 2.39.2