From: Andre Noll Date: Thu, 4 Jul 2019 07:04:56 +0000 (+0200) Subject: ogg_afh_common.c: Check return value of ogg_page_granulepos(). X-Git-Tag: v0.6.3~28^2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=730bae4a2d2579b862a34c6436d1652823899b90 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. --- 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;