]> git.tue.mpg.de Git - paraslash.git/commitdiff
mp4: Use a for-loop in mp4ff_parse_tag().
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 9 Aug 2021 18:22:16 +0000 (20:22 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:35 +0000 (21:37 +0200)
This is equivalent but will allow us to further reduce the indentation
because we now can easily continue the loop.

mp4.c

diff --git a/mp4.c b/mp4.c
index 8f1ddec2d842d1531428ab75b0c5027c3da65492..537788639e3a2d5991f1bc901205804389c49320 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -957,14 +957,18 @@ static int32_t mp4ff_parse_tag(mp4ff_t * f, const uint8_t parent_atom_type,
 {
        uint8_t atom_type;
        uint8_t header_size = 0;
-       uint64_t subsize, sumsize = 0;
+       uint64_t subsize, sumsize;
        char *name = NULL;
        char *data = NULL;
        uint32_t done = 0;
        uint32_t len = 0;
+       uint64_t destpos;
 
-       while (sumsize < size && !f->stream->read_error) {      /* CVE-2017-9222 */
-               uint64_t destpos;
+       for (
+               sumsize = 0;
+               sumsize < size && !f->stream->read_error; /* CVE-2017-9222 */
+               mp4ff_set_position(f, destpos), sumsize += subsize
+       ) {
                subsize = mp4ff_atom_read_header(f, &atom_type, &header_size);
                destpos = mp4ff_position(f) + subsize - header_size;
                if (done)
@@ -1031,8 +1035,6 @@ static int32_t mp4ff_parse_tag(mp4ff_t * f, const uint8_t parent_atom_type,
                                name = mp4ff_read_string(f, (uint32_t) (subsize - (header_size + 4)));
                        }
                }
-               mp4ff_set_position(f, destpos);
-               sumsize += subsize;
        }
 
        if (data) {