[PATCH] fixed #1782 (fuzz)
authorjeanlf <jeanlf@gpac.io>
Mon, 10 May 2021 09:14:03 +0000 (11:14 +0200)
committerAron Xu <aron@debian.org>
Tue, 23 May 2023 11:53:25 +0000 (12:53 +0100)
Gbp-Pq: Name CVE-2021-33361.patch

applications/mp4box/main.c
src/isomedia/box_code_adobe.c

index 99c8bf9c59b3101dc06c542fc14fff8b8c015d41..aec7ef6d9fd368204375c2b591e3c85de08e8c2c 100644 (file)
@@ -2648,6 +2648,14 @@ u32 mp4box_cleanup(u32 ret_code) {
        }
        if (logfile) gf_fclose(logfile);
        gf_sys_close();
+
+#ifdef GPAC_MEMORY_TRACKING
+       if (mem_track && (gf_memory_size() || gf_file_handles_count() )) {
+               gf_log_set_tool_level(GF_LOG_MEMORY, GF_LOG_INFO);
+               gf_memory_print();
+       }
+#endif
+
        return ret_code;
 }
 
index 711d84bf0d95c57bee27a17573a30b8a52826143..c6ad43efd4c11d20259607de5ac234ecd3f10f87 100644 (file)
@@ -382,6 +382,7 @@ GF_Err afra_box_read(GF_Box *s, GF_BitStream *bs)
        for (i=0; i<ptr->entry_count; i++) {
                GF_AfraEntry *ae = gf_malloc(sizeof(GF_AfraEntry));
                if (!ae) return GF_OUT_OF_MEM;
+               gf_list_insert(ptr->local_access_entries, ae, i);
 
                ISOM_DECREASE_SIZE(ptr, 8)
                ae->time = gf_bs_read_u64(bs);
@@ -392,8 +393,6 @@ GF_Err afra_box_read(GF_Box *s, GF_BitStream *bs)
                        ISOM_DECREASE_SIZE(ptr, 4)
                        ae->offset = gf_bs_read_u32(bs);
                }
-
-               gf_list_insert(ptr->local_access_entries, ae, i);
        }
 
        if (ptr->global_entries) {
@@ -402,6 +401,8 @@ GF_Err afra_box_read(GF_Box *s, GF_BitStream *bs)
                for (i=0; i<ptr->global_entry_count; i++) {
                        GF_GlobalAfraEntry *ae = gf_malloc(sizeof(GF_GlobalAfraEntry));
                        if (!ae) return GF_OUT_OF_MEM;
+                       gf_list_insert(ptr->global_access_entries, ae, i);
+
                        ISOM_DECREASE_SIZE(ptr, 8)
                        ae->time = gf_bs_read_u64(bs);
                        if (ptr->long_ids) {
@@ -422,8 +423,6 @@ GF_Err afra_box_read(GF_Box *s, GF_BitStream *bs)
                                ae->afra_offset = gf_bs_read_u32(bs);
                                ae->offset_from_afra = gf_bs_read_u32(bs);
                        }
-
-                       gf_list_insert(ptr->global_access_entries, ae, i);
                }
        }