Hi, there.

There is a segmentation fault in the newest master branch 5922ba762a.
Here is the reproducing command:
~~~~
mp42aac poc /dev/null
~~~~

POC:

[poc.zip](https://github.com/axiomatic-systems/Bento4/files/7005212/mp42aac-seg-action108.zip)
(unzip first)

Here is the reproduce trace reported by ASAN:
~~~~
==48220==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000060273c bp 0x7ffd82575410 sp 0x7ffd82575350 T0)
 ==48220==The signal is caused by a READ memory access.
 ==48220==Hint: address points to the zero page.
     #0 0x60273c in AP4_DescriptorListWriter::Action(AP4_Descriptor*) const /mnt/data/playground/Bento4/Source/C++/Core/Ap4Descriptor.h:108:28
     #1 0x60ccc7 in AP4_List<AP4_Descriptor>::Apply(AP4_List<AP4_Descriptor>::Item::Operator const&) const /mnt/data/playground/Bento4/Source/C++/Core/Ap4List.h:353:12
     #2 0x60ccc7 in AP4_EsDescriptor::WriteFields(AP4_ByteStream&) /mnt/data/playground/Bento4/Source/C++/Core/Ap4EsDescriptor.cpp:163:22
     #3 0x60fee9 in AP4_Expandable::Write(AP4_ByteStream&) /mnt/data/playground/Bento4/Source/C++/Core/Ap4Expandable.cpp:109:5
     #4 0x60f603 in AP4_EsdsAtom::WriteFields(AP4_ByteStream&) /mnt/data/playground/Bento4/Source/C++/Core/Ap4EsdsAtom.cpp:99:48
     #5 0x581ee1 in AP4_Atom::Write(AP4_ByteStream&) /mnt/data/playground/Bento4/Source/C++/Core/Ap4Atom.cpp:229:14
     #6 0x582934 in AP4_Atom::Clone() /mnt/data/playground/Bento4/Source/C++/Core/Ap4Atom.cpp:316:9
     #7 0x5206ab in AP4_SampleDescription::AP4_SampleDescription(AP4_SampleDescription::Type, unsigned int, AP4_AtomParent*) /mnt/data/playground/Bento4/Source/C++/Core/Ap4SampleDescription.cpp:135:41
     #8 0x50ebb1 in AP4_GenericAudioSampleDescription::AP4_GenericAudioSampleDescription(unsigned int, unsigned int, unsigned short, unsigned short, AP4_AtomParent*) /mnt/data/playground/Bento4/Source/C++/Core/Ap4SampleDescription.h:258:9
     #9 0x50ebb1 in AP4_EncaSampleEntry::ToTargetSampleDescription(unsigned int) /mnt/data/playground/Bento4/Source/C++/Core/Ap4Protection.cpp:147:24
     #10 0x50e33e in AP4_EncaSampleEntry::ToSampleDescription() /mnt/data/playground/Bento4/Source/C++/Core/Ap4Protection.cpp:98:13
     #11 0x5474b4 in AP4_StsdAtom::GetSampleDescription(unsigned int) /mnt/data/playground/Bento4/Source/C++/Core/Ap4StsdAtom.cpp:181:53
     #12 0x59f07e in AP4_AtomSampleTable::GetSampleDescription(unsigned int) /mnt/data/playground/Bento4/Source/C++/Core/Ap4AtomSampleTable.cpp:207:37
     #13 0x54b8ad in AP4_Track::GetSampleDescription(unsigned int) /mnt/data/playground/Bento4/Source/C++/Core/Ap4Track.cpp:447:43
     #14 0x4f6876 in main /mnt/data/playground/Bento4/Source/C++/Apps/Mp42Aac/Mp42Aac.cpp:268:39
     #15 0x7f564c8c283f in __libc_start_main /build/glibc-S7Ft5T/glibc-2.23/csu/../csu/libc-start.c:291
     #16 0x41c1b8 in _start (/mnt/data/playground/Bento4/build/mp42aac+0x41c1b8)
 
 AddressSanitizer can not provide additional info.
 SUMMARY: AddressSanitizer: SEGV /mnt/data/playground/Bento4/Source/C++/Core/Ap4Descriptor.h:108:28 in AP4_DescriptorListWriter::Action(AP4_Descriptor*) const
 ==48220==ABORTING

~~~~


The cause might due to the incomplete nullity check of the input parameter.
<img width="636" alt="image" src="https://user-images.githubusercontent.com/7632714/129852400-7995f325-c305-4501-9591-8d9aeebf6561.png">


SEGV caused by null pointer dereference in mp42aac with AP4_DescriptorListWriter::Action in Ap4Descriptor.h:108
This is a GitHub Issue
repo:Bento4
owner:axiomatic-systems
Title : SEGV caused by null pointer dereference in mp42aac with AP4_DescriptorListWriter::Action in Ap4Descriptor.h:108
Issue date:

--- start body ---
Hi, there.

There is a segmentation fault in the newest master branch 5922ba762a.
Here is the reproducing command:
~~~~
mp42aac poc /dev/null
~~~~

POC:

[poc.zip](https://github.com/axiomatic-systems/Bento4/files/7005212/mp42aac-seg-action108.zip)
(unzip first)

Here is the reproduce trace reported by ASAN:
~~~~
==48220==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000060273c bp 0x7ffd82575410 sp 0x7ffd82575350 T0)
 ==48220==The signal is caused by a READ memory access.
 ==48220==Hint: address points to the zero page.
     #0 0x60273c in AP4_DescriptorListWriter::Action(AP4_Descriptor*) const /mnt/data/playground/Bento4/Source/C++/Core/Ap4Descriptor.h:108:28
     #1 0x60ccc7 in AP4_List<AP4_Descriptor>::Apply(AP4_List<AP4_Descriptor>::Item::Operator const&) const /mnt/data/playground/Bento4/Source/C++/Core/Ap4List.h:353:12
     #2 0x60ccc7 in AP4_EsDescriptor::WriteFields(AP4_ByteStream&) /mnt/data/playground/Bento4/Source/C++/Core/Ap4EsDescriptor.cpp:163:22
     #3 0x60fee9 in AP4_Expandable::Write(AP4_ByteStream&) /mnt/data/playground/Bento4/Source/C++/Core/Ap4Expandable.cpp:109:5
     #4 0x60f603 in AP4_EsdsAtom::WriteFields(AP4_ByteStream&) /mnt/data/playground/Bento4/Source/C++/Core/Ap4EsdsAtom.cpp:99:48
     #5 0x581ee1 in AP4_Atom::Write(AP4_ByteStream&) /mnt/data/playground/Bento4/Source/C++/Core/Ap4Atom.cpp:229:14
     #6 0x582934 in AP4_Atom::Clone() /mnt/data/playground/Bento4/Source/C++/Core/Ap4Atom.cpp:316:9
     #7 0x5206ab in AP4_SampleDescription::AP4_SampleDescription(AP4_SampleDescription::Type, unsigned int, AP4_AtomParent*) /mnt/data/playground/Bento4/Source/C++/Core/Ap4SampleDescription.cpp:135:41
     #8 0x50ebb1 in AP4_GenericAudioSampleDescription::AP4_GenericAudioSampleDescription(unsigned int, unsigned int, unsigned short, unsigned short, AP4_AtomParent*) /mnt/data/playground/Bento4/Source/C++/Core/Ap4SampleDescription.h:258:9
     #9 0x50ebb1 in AP4_EncaSampleEntry::ToTargetSampleDescription(unsigned int) /mnt/data/playground/Bento4/Source/C++/Core/Ap4Protection.cpp:147:24
     #10 0x50e33e in AP4_EncaSampleEntry::ToSampleDescription() /mnt/data/playground/Bento4/Source/C++/Core/Ap4Protection.cpp:98:13
     #11 0x5474b4 in AP4_StsdAtom::GetSampleDescription(unsigned int) /mnt/data/playground/Bento4/Source/C++/Core/Ap4StsdAtom.cpp:181:53
     #12 0x59f07e in AP4_AtomSampleTable::GetSampleDescription(unsigned int) /mnt/data/playground/Bento4/Source/C++/Core/Ap4AtomSampleTable.cpp:207:37
     #13 0x54b8ad in AP4_Track::GetSampleDescription(unsigned int) /mnt/data/playground/Bento4/Source/C++/Core/Ap4Track.cpp:447:43
     #14 0x4f6876 in main /mnt/data/playground/Bento4/Source/C++/Apps/Mp42Aac/Mp42Aac.cpp:268:39
     #15 0x7f564c8c283f in __libc_start_main /build/glibc-S7Ft5T/glibc-2.23/csu/../csu/libc-start.c:291
     #16 0x41c1b8 in _start (/mnt/data/playground/Bento4/build/mp42aac+0x41c1b8)
 
 AddressSanitizer can not provide additional info.
 SUMMARY: AddressSanitizer: SEGV /mnt/data/playground/Bento4/Source/C++/Core/Ap4Descriptor.h:108:28 in AP4_DescriptorListWriter::Action(AP4_Descriptor*) const
 ==48220==ABORTING

~~~~


The cause might due to the incomplete nullity check of the input parameter.
<img width="636" alt="image" src="https://user-images.githubusercontent.com/7632714/129852400-7995f325-c305-4501-9591-8d9aeebf6561.png">


--- end body ---
