Hi

I found an crash erro.

System info：
Ubuntu 20.04 : clang 10.0.0 , gcc 9.3.0

Bento4 version 1.6.0.0

commit:0c7705733de80172712e487dd6fdd28387fd7184

[poc.zip](https://github.com/axiomatic-systems/Bento4/files/6463812/poc1.zip)

------------------------------------------
Verification steps：
1.Get the source code of Bento4
2.Compile the Bento4

```bash
$ cd Bento4
$ mkdir check_build && cd check_build
$ cmake ../ -DCMAKE_C_COMPILER=clang  -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="-fsanitize=address" -DCMAKE_CXX_FLAGS="-fsanitize=address"
$ make -j 32
```

3.run mp42aac
```bash
$ ./mp42aac poc.mp4
```
asan
```bash
Audio Track:
  duration: 0 ms
  sample count: 255
AddressSanitizer:DEADLYSIGNAL
=================================================================
==2609245==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x0000006939ae bp 0x7fffb9ecb3f0 sp 0x7fffb9ecb250 T0)
==2609245==The signal is caused by a READ memory access.
==2609245==Hint: address points to the zero page.
    #0 0x6939ae in AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4StszAtom.cpp:154:27
    #1 0x57553f in AP4_AtomSampleTable::GetSample(unsigned int, AP4_Sample&) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4AtomSampleTable.cpp:162:30
    #2 0x523d78 in AP4_Track::GetSample(unsigned int, AP4_Sample&) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4Track.cpp:435:43
    #3 0x523d78 in AP4_Track::ReadSample(unsigned int, AP4_Sample&, AP4_DataBuffer&) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4Track.cpp:469:14
    #4 0x4c8239 in WriteSamples(AP4_Track*, AP4_SampleDescription*, AP4_ByteStream*) /home/hh/Downloads/Bento4/Source/C++/Apps/Mp42Aac/Mp42Aac.cpp:192:12
    #5 0x4c8239 in main /home/hh/Downloads/Bento4/Source/C++/Apps/Mp42Aac/Mp42Aac.cpp:281:13
    #6 0x7ff7705870b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #7 0x41c8ad in _start (/home/hh/Downloads/Bento4/afl_fuzz/mp42aac+0x41c8ad)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/hh/Downloads/Bento4/Source/C++/Core/Ap4StszAtom.cpp:154:27 in AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)
==2609245==ABORTING
```

gdb info
```bash
Audio Track:
  duration: 0 ms
  sample count: 255

Program received signal SIGSEGV, Segmentation fault.
[----------------------------------registers-----------------------------------]
RAX: 0x0 
RBX: 0x7fffffffddc0 --> 0x1 
RCX: 0xc0e000000a6 --> 0x0 
RDX: 0x7fffffffddb0 --> 0x60c000000000 --> 0xcc6e96b9 --> 0x0 
RSI: 0x0 
RDI: 0x607000000530 --> 0x0 
RBP: 0x7fffffffde70 --> 0x7fffffffe1b0 --> 0x0 
RSP: 0x7fffffffdcd0 --> 0xe60e4 
RIP: 0x6939ae (<AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+302>:	mov    r8d,DWORD PTR [r8])
R8 : 0x0 
R9 : 0x480 
R10: 0x7fffffffdce0 --> 0x41b58ab3 
R11: 0xffffffffbb0 --> 0x0 
R12: 0x7fffffffddb0 --> 0x60c000000000 --> 0xcc6e96b9 --> 0x0 
R13: 0xffffffffbb6 --> 0x0 
R14: 0x10007fff7b9c --> 0xf204f204f1f1f1f1 
R15: 0x7fffffffdd80 --> 0x0
EFLAGS: 0x10246 (carry PARITY adjust ZERO sign trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
   0x69399e <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+286>:	mov    sil,BYTE PTR [rsi+0x7fff8000]
   0x6939a5 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+293>:	test   sil,sil
   0x6939a8 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+296>:	jne    0x693a52 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+466>
=> 0x6939ae <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+302>:	mov    r8d,DWORD PTR [r8]
   0x6939b1 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+305>:	jmp    0x6939bb <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+315>
   0x6939b3 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+307>:	mov    eax,0xfffffff4
   0x6939b8 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+312>:	xor    r8d,r8d
   0x6939bb <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+315>:	mov    rcx,rdx
[------------------------------------stack-------------------------------------]
0000| 0x7fffffffdcd0 --> 0xe60e4 
0008| 0x7fffffffdcd8 --> 0x575540 (<AP4_AtomSampleTable::GetSample(unsigned int, AP4_Sample&)+3552>:	test   eax,eax)
0016| 0x7fffffffdce0 --> 0x41b58ab3 
0024| 0x7fffffffdce8 --> 0x71be85 ("10 32 4 9 chunk:104 48 4 8 skip:104 64 4 8 desc:104 80 8 10 offset:112 112 4 13 offset_32:114 128 4 8 size:124 144 4 14 cts_offset:140 160 8 7 dts:141 192 4 12 duration:142 208 4 15 sample_size:158")
0032| 0x7fffffffdcf0 --> 0x574760 (<AP4_AtomSampleTable::GetSample(unsigned int, AP4_Sample&)>:	lea    rsp,[rsp-0x98])
0040| 0x7fffffffdcf8 --> 0x60c000000100 --> 0x7059d0 --> 0x505850 (<AP4_MpegAudioSampleDescription::~AP4_MpegAudioSampleDescription()>:	lea    rsp,[rsp-0x98])
0048| 0x7fffffffdd00 --> 0x1 
0056| 0x7fffffffdd08 --> 0xfffffffffffffffe 
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value
Stopped reason: SIGSEGV
0x00000000006939ae in AP4_StszAtom::GetSampleSize (this=<optimized out>, sample=<optimized out>, sample_size=@0x7fffffffddb0: 0x0) at /home/hh/Downloads/Bento4/Source/C++/Core/Ap4StszAtom.cpp:154
154	            sample_size = m_Entries[sample - 1];
```


NULL pointer dereference of Ap4StszAtom.cpp in function GetSampleSize
This is a GitHub Issue
repo:Bento4
owner:axiomatic-systems
Title : NULL pointer dereference of Ap4StszAtom.cpp in function GetSampleSize
Issue date:

--- start body ---
Hi

I found an crash erro.

System info：
Ubuntu 20.04 : clang 10.0.0 , gcc 9.3.0

Bento4 version 1.6.0.0

commit:0c7705733de80172712e487dd6fdd28387fd7184

[poc.zip](https://github.com/axiomatic-systems/Bento4/files/6463812/poc1.zip)

------------------------------------------
Verification steps：
1.Get the source code of Bento4
2.Compile the Bento4

```bash
$ cd Bento4
$ mkdir check_build && cd check_build
$ cmake ../ -DCMAKE_C_COMPILER=clang  -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="-fsanitize=address" -DCMAKE_CXX_FLAGS="-fsanitize=address"
$ make -j 32
```

3.run mp42aac
```bash
$ ./mp42aac poc.mp4
```
asan
```bash
Audio Track:
  duration: 0 ms
  sample count: 255
AddressSanitizer:DEADLYSIGNAL
=================================================================
==2609245==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x0000006939ae bp 0x7fffb9ecb3f0 sp 0x7fffb9ecb250 T0)
==2609245==The signal is caused by a READ memory access.
==2609245==Hint: address points to the zero page.
    #0 0x6939ae in AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4StszAtom.cpp:154:27
    #1 0x57553f in AP4_AtomSampleTable::GetSample(unsigned int, AP4_Sample&) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4AtomSampleTable.cpp:162:30
    #2 0x523d78 in AP4_Track::GetSample(unsigned int, AP4_Sample&) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4Track.cpp:435:43
    #3 0x523d78 in AP4_Track::ReadSample(unsigned int, AP4_Sample&, AP4_DataBuffer&) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4Track.cpp:469:14
    #4 0x4c8239 in WriteSamples(AP4_Track*, AP4_SampleDescription*, AP4_ByteStream*) /home/hh/Downloads/Bento4/Source/C++/Apps/Mp42Aac/Mp42Aac.cpp:192:12
    #5 0x4c8239 in main /home/hh/Downloads/Bento4/Source/C++/Apps/Mp42Aac/Mp42Aac.cpp:281:13
    #6 0x7ff7705870b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #7 0x41c8ad in _start (/home/hh/Downloads/Bento4/afl_fuzz/mp42aac+0x41c8ad)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/hh/Downloads/Bento4/Source/C++/Core/Ap4StszAtom.cpp:154:27 in AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)
==2609245==ABORTING
```

gdb info
```bash
Audio Track:
  duration: 0 ms
  sample count: 255

Program received signal SIGSEGV, Segmentation fault.
[----------------------------------registers-----------------------------------]
RAX: 0x0 
RBX: 0x7fffffffddc0 --> 0x1 
RCX: 0xc0e000000a6 --> 0x0 
RDX: 0x7fffffffddb0 --> 0x60c000000000 --> 0xcc6e96b9 --> 0x0 
RSI: 0x0 
RDI: 0x607000000530 --> 0x0 
RBP: 0x7fffffffde70 --> 0x7fffffffe1b0 --> 0x0 
RSP: 0x7fffffffdcd0 --> 0xe60e4 
RIP: 0x6939ae (<AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+302>:	mov    r8d,DWORD PTR [r8])
R8 : 0x0 
R9 : 0x480 
R10: 0x7fffffffdce0 --> 0x41b58ab3 
R11: 0xffffffffbb0 --> 0x0 
R12: 0x7fffffffddb0 --> 0x60c000000000 --> 0xcc6e96b9 --> 0x0 
R13: 0xffffffffbb6 --> 0x0 
R14: 0x10007fff7b9c --> 0xf204f204f1f1f1f1 
R15: 0x7fffffffdd80 --> 0x0
EFLAGS: 0x10246 (carry PARITY adjust ZERO sign trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
   0x69399e <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+286>:	mov    sil,BYTE PTR [rsi+0x7fff8000]
   0x6939a5 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+293>:	test   sil,sil
   0x6939a8 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+296>:	jne    0x693a52 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+466>
=> 0x6939ae <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+302>:	mov    r8d,DWORD PTR [r8]
   0x6939b1 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+305>:	jmp    0x6939bb <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+315>
   0x6939b3 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+307>:	mov    eax,0xfffffff4
   0x6939b8 <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+312>:	xor    r8d,r8d
   0x6939bb <AP4_StszAtom::GetSampleSize(unsigned int, unsigned int&)+315>:	mov    rcx,rdx
[------------------------------------stack-------------------------------------]
0000| 0x7fffffffdcd0 --> 0xe60e4 
0008| 0x7fffffffdcd8 --> 0x575540 (<AP4_AtomSampleTable::GetSample(unsigned int, AP4_Sample&)+3552>:	test   eax,eax)
0016| 0x7fffffffdce0 --> 0x41b58ab3 
0024| 0x7fffffffdce8 --> 0x71be85 ("10 32 4 9 chunk:104 48 4 8 skip:104 64 4 8 desc:104 80 8 10 offset:112 112 4 13 offset_32:114 128 4 8 size:124 144 4 14 cts_offset:140 160 8 7 dts:141 192 4 12 duration:142 208 4 15 sample_size:158")
0032| 0x7fffffffdcf0 --> 0x574760 (<AP4_AtomSampleTable::GetSample(unsigned int, AP4_Sample&)>:	lea    rsp,[rsp-0x98])
0040| 0x7fffffffdcf8 --> 0x60c000000100 --> 0x7059d0 --> 0x505850 (<AP4_MpegAudioSampleDescription::~AP4_MpegAudioSampleDescription()>:	lea    rsp,[rsp-0x98])
0048| 0x7fffffffdd00 --> 0x1 
0056| 0x7fffffffdd08 --> 0xfffffffffffffffe 
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value
Stopped reason: SIGSEGV
0x00000000006939ae in AP4_StszAtom::GetSampleSize (this=<optimized out>, sample=<optimized out>, sample_size=@0x7fffffffddb0: 0x0) at /home/hh/Downloads/Bento4/Source/C++/Core/Ap4StszAtom.cpp:154
154	            sample_size = m_Entries[sample - 1];
```


--- end body ---
