Hi, i find a `heap-use-after-free` in mp4ts with the [input](https://user-images.githubusercontent.com/110105969/185295922-f2da25ac-cdb2-4255-aeaa-6bdfb790847f.mp4) file, the output are as follows.
```bash
=================================================================
==36710==ERROR: AddressSanitizer: heap-use-after-free on address 0x604000001498 at pc 0x0000004d9856 bp 0x7fffffffd6e0 sp 0x7f
READ of size 8 at 0x604000001498 thread T0
    #0 0x4d9855 in AP4_LinearReader::Advance(bool) (./Bento4/check_build/mp42ts+0x4d9855)
    #1 0x4d9d8f in AP4_LinearReader::ReadNextSample(unsigned int, AP4_Sample&, AP4_DataBuffer&) (./Bento4/check
    #2 0x4c8ec6 in main (./Bento4/check_build/mp42ts+0x4c8ec6)
    #3 0x7ffff7a70082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
    #4 0x41c61d in _start (./Bento4/check_build/mp42ts+0x41c61d)

0x604000001498 is located 8 bytes inside of 48-byte region [0x604000001490,0x6040000014c0)
freed by thread T0 here:
    #0 0x4c4d2d in operator delete(void*) (./Bento4/check_build/mp42ts+0x4c4d2d)
    #1 0x4d9596 in AP4_LinearReader::Advance(bool) (./Bento4/check_build/mp42ts+0x4d9596)

previously allocated by thread T0 here:
    #0 0x4c44cd in operator new(unsigned long) (./Bento4/check_build/mp42ts+0x4c44cd)
    #1 0x4d90b7 in AP4_LinearReader::Advance(bool) (./Bento4/check_build/mp42ts+0x4d90b7)

SUMMARY: AddressSanitizer: heap-use-after-free (./Bento4/check_build/mp42ts+0x4d9855) in AP4_LinearReader::Adva
Shadow bytes around the buggy address:
  0x0c087fff8240: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fa
  0x0c087fff8250: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fa
  0x0c087fff8260: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fa
  0x0c087fff8270: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fa
  0x0c087fff8280: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fa
=>0x0c087fff8290: fa fa fd[fd]fd fd fd fd fa fa fd fd fd fd fd fa
  0x0c087fff82a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff82b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff82c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff82d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff82e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==36710==ABORTING
```
You can use the following setp to reproduce the problem.
```bash
git clone https://github.com/axiomatic-systems/Bento4
cd Bento4/
mkdir check && cd check
cmake ../ -DCMAKE_C_COMPILER=clang  -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="-fsanitize=address" -DCMAKE_CXX_FLAGS="-fsanitize=address" -DCMAKE_BUILD_TYPE=Release
make -j
./mp42ts ./cur_input.mp4 ./out
```
Thanks for your time!

heap-use-after-free in mp42ts
This is a GitHub Issue
repo:Bento4
owner:axiomatic-systems
Title : heap-use-after-free in mp42ts
Issue date:

--- start body ---
Hi, i find a `heap-use-after-free` in mp4ts with the [input](https://user-images.githubusercontent.com/110105969/185295922-f2da25ac-cdb2-4255-aeaa-6bdfb790847f.mp4) file, the output are as follows.
```bash
=================================================================
==36710==ERROR: AddressSanitizer: heap-use-after-free on address 0x604000001498 at pc 0x0000004d9856 bp 0x7fffffffd6e0 sp 0x7f
READ of size 8 at 0x604000001498 thread T0
    #0 0x4d9855 in AP4_LinearReader::Advance(bool) (./Bento4/check_build/mp42ts+0x4d9855)
    #1 0x4d9d8f in AP4_LinearReader::ReadNextSample(unsigned int, AP4_Sample&, AP4_DataBuffer&) (./Bento4/check
    #2 0x4c8ec6 in main (./Bento4/check_build/mp42ts+0x4c8ec6)
    #3 0x7ffff7a70082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
    #4 0x41c61d in _start (./Bento4/check_build/mp42ts+0x41c61d)

0x604000001498 is located 8 bytes inside of 48-byte region [0x604000001490,0x6040000014c0)
freed by thread T0 here:
    #0 0x4c4d2d in operator delete(void*) (./Bento4/check_build/mp42ts+0x4c4d2d)
    #1 0x4d9596 in AP4_LinearReader::Advance(bool) (./Bento4/check_build/mp42ts+0x4d9596)

previously allocated by thread T0 here:
    #0 0x4c44cd in operator new(unsigned long) (./Bento4/check_build/mp42ts+0x4c44cd)
    #1 0x4d90b7 in AP4_LinearReader::Advance(bool) (./Bento4/check_build/mp42ts+0x4d90b7)

SUMMARY: AddressSanitizer: heap-use-after-free (./Bento4/check_build/mp42ts+0x4d9855) in AP4_LinearReader::Adva
Shadow bytes around the buggy address:
  0x0c087fff8240: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fa
  0x0c087fff8250: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fa
  0x0c087fff8260: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fa
  0x0c087fff8270: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fa
  0x0c087fff8280: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fa
=>0x0c087fff8290: fa fa fd[fd]fd fd fd fd fa fa fd fd fd fd fd fa
  0x0c087fff82a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff82b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff82c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff82d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff82e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==36710==ABORTING
```
You can use the following setp to reproduce the problem.
```bash
git clone https://github.com/axiomatic-systems/Bento4
cd Bento4/
mkdir check && cd check
cmake ../ -DCMAKE_C_COMPILER=clang  -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="-fsanitize=address" -DCMAKE_CXX_FLAGS="-fsanitize=address" -DCMAKE_BUILD_TYPE=Release
make -j
./mp42ts ./cur_input.mp4 ./out
```
Thanks for your time!

--- end body ---
