]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
ogg_afh_common.c: Check return value of ogg_page_granulepos().
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 4 Jul 2019 07:04:56 +0000 (09:04 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 4 Jul 2019 07:04:56 +0000 (09:04 +0200)
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

index 12a152062f2bf49beebd6d3838e3514d1ec0ee3d..3e36bdd5b1e9d3615695f975541bf69c0cc05093 100644 (file)
@@ -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;