Thanks for reporting your issue. Please make sure these boxes are checked before submitting your issue - thank you!

- [x] I looked for a similar issue and couldn't find any.
- [x] I tried with the latest version of GPAC. Installers available at http://gpac.io/downloads/gpac-nightly-builds/
- [x] I give enough information for contributors to reproduce my issue (meaningful title, github labels, platform and compiler, command-line ...). I can share files anonymously with this dropbox: https://www.mediafire.com/filedrop/filedrop_hosted.php?drop=eec9e058a9486fe4e99c33021481d9e1826ca9dbc242a6cfaab0fe95da5e5d95

Hi, there.

There is a segmentation fault caused by invalid memory write in isom_write.c:8904 in newest commit  6c7e0564303fa1690a744ad51a6b473564ea6d1a.  It seems to be an incomplete fix of #2166.

Here is my environment, compiler info and gpac version:
~~~~
Distributor ID:	Ubuntu
Description:	20.04.6 LTS
Compiler: Clang 14.0.1

MP4Box - GPAC version 2.3-DEV-rev543-g6c7e05643-master
(c) 2000-2023 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io

Please cite our work in your research:
	GPAC Filters: https://doi.org/10.1145/3339825.3394929
	GPAC: https://doi.org/10.1145/1291233.1291452

GPAC Configuration: --disable-shared
Features: GPAC_CONFIG_LINUX GPAC_64_BITS GPAC_HAS_IPV6 GPAC_HAS_SSL GPAC_HAS_SOCK_UN GPAC_MINIMAL_ODF GPAC_HAS_QJS GPAC_HAS_JPEG GPAC_HAS_PNG GPAC_HAS_JP2 GPAC_HAS_VORBIS GPAC_HAS_LINUX_DVB  GPAC_DISABLE_3D 
~~~~

To reproduce, run
~~~~
./MP4Box -hint poc
~~~~

POC:

[poc.zip](https://github.com/gpac/gpac/files/12690029/mp4box-seg-gf_isom_add_sample_aux_info_internal8904.zip)
(unzip first)

Here is the trace reported by gdb:
~~~~
#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:306
#1  0x00007ffff74bb356 in gf_isom_add_sample_aux_info_internal (trak=trak@entry=0x6a57b0, _traf=_traf@entry=0x0, sampleNumber=sampleNumber@entry=178956971, 
    aux_type=1668050531, aux_info=0, data=data@entry=0x6abb60 "\305", <incomplete sequence \321>, size=24)
    at  /benchmark/gpac/src/isomedia/isom_write.c:8904
#2  0x00007ffff74f90c7 in MergeTrack (trak=<optimized out>, trak@entry=0x6a57b0, traf=<optimized out>, traf@entry=0x6a7dd0, moof_box=moof_box@entry=0x6a7360, 
    moof_offset=<optimized out>, compressed_diff=<optimized out>, cumulated_offset=<optimized out>, cumulated_offset@entry=0x7fffffffa8d8)
    at  /benchmark/gpac/src/isomedia/track.c:1248
#3  0x00007ffff747073c in MergeFragment (moof=0x6a7360, mov=mov@entry=0x6c1220) at  /benchmark/gpac/src/isomedia/isom_intern.c:92
#4  0x00007ffff7473529 in gf_isom_parse_movie_boxes_internal (mov=0x6c1220, boxType=0x0, bytesMissing=0x7fffffffa9b8, progressive_mode=GF_FALSE)
    at  /benchmark/gpac/src/isomedia/isom_intern.c:736
#5  gf_isom_parse_movie_boxes (mov=mov@entry=0x6c1220, boxType=boxType@entry=0x0, bytesMissing=bytesMissing@entry=0x7fffffffa9b8, 
    progressive_mode=progressive_mode@entry=GF_FALSE) at  /benchmark/gpac/src/isomedia/isom_intern.c:897
#6  0x00007ffff7474361 in gf_isom_open_file (
    fileName=0x7fffffffe5a5 " /testoutput/mp4hint-1/default/crashes/id:000000,sig:11,src:000992,time:15923297,execs:478509,op:havoc,rep:2", 
    OpenMode=GF_ISOM_OPEN_EDIT, tmp_dir=<optimized out>) at  /benchmark/gpac/src/isomedia/isom_intern.c:1023
#7  0x0000000000423593 in mp4box_main (argc=3, argv=0x7fffffffe2f8) at  /benchmark/gpac/applications/mp4box/mp4box.c:6297
#8  0x00007ffff6f2c083 in __libc_start_main (main=0x42a530 <main>, argc=3, argv=0x7fffffffe2f8, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffffffe2e8) at ../csu/libc-start.c:308
#9  0x0000000000410e5e in _start ()
~~~~


Detailed guidelines: http://gpac.io/bug-reporting/

Segmentation fault caused by invalid memory write using mp4box in gf_isom_add_sample_aux_info_internal, isom_write.c:8904
This is a GitHub Issue
repo:gpac
owner:gpac
Title : Segmentation fault caused by invalid memory write using mp4box in gf_isom_add_sample_aux_info_internal, isom_write.c:8904
Issue date:

--- start body ---
Thanks for reporting your issue. Please make sure these boxes are checked before submitting your issue - thank you!

- [x] I looked for a similar issue and couldn't find any.
- [x] I tried with the latest version of GPAC. Installers available at http://gpac.io/downloads/gpac-nightly-builds/
- [x] I give enough information for contributors to reproduce my issue (meaningful title, github labels, platform and compiler, command-line ...). I can share files anonymously with this dropbox: https://www.mediafire.com/filedrop/filedrop_hosted.php?drop=eec9e058a9486fe4e99c33021481d9e1826ca9dbc242a6cfaab0fe95da5e5d95

Hi, there.

There is a segmentation fault caused by invalid memory write in isom_write.c:8904 in newest commit  6c7e0564303fa1690a744ad51a6b473564ea6d1a.  It seems to be an incomplete fix of #2166.

Here is my environment, compiler info and gpac version:
~~~~
Distributor ID:	Ubuntu
Description:	20.04.6 LTS
Compiler: Clang 14.0.1

MP4Box - GPAC version 2.3-DEV-rev543-g6c7e05643-master
(c) 2000-2023 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io

Please cite our work in your research:
	GPAC Filters: https://doi.org/10.1145/3339825.3394929
	GPAC: https://doi.org/10.1145/1291233.1291452

GPAC Configuration: --disable-shared
Features: GPAC_CONFIG_LINUX GPAC_64_BITS GPAC_HAS_IPV6 GPAC_HAS_SSL GPAC_HAS_SOCK_UN GPAC_MINIMAL_ODF GPAC_HAS_QJS GPAC_HAS_JPEG GPAC_HAS_PNG GPAC_HAS_JP2 GPAC_HAS_VORBIS GPAC_HAS_LINUX_DVB  GPAC_DISABLE_3D 
~~~~

To reproduce, run
~~~~
./MP4Box -hint poc
~~~~

POC:

[poc.zip](https://github.com/gpac/gpac/files/12690029/mp4box-seg-gf_isom_add_sample_aux_info_internal8904.zip)
(unzip first)

Here is the trace reported by gdb:
~~~~
#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:306
#1  0x00007ffff74bb356 in gf_isom_add_sample_aux_info_internal (trak=trak@entry=0x6a57b0, _traf=_traf@entry=0x0, sampleNumber=sampleNumber@entry=178956971, 
    aux_type=1668050531, aux_info=0, data=data@entry=0x6abb60 "\305", <incomplete sequence \321>, size=24)
    at  /benchmark/gpac/src/isomedia/isom_write.c:8904
#2  0x00007ffff74f90c7 in MergeTrack (trak=<optimized out>, trak@entry=0x6a57b0, traf=<optimized out>, traf@entry=0x6a7dd0, moof_box=moof_box@entry=0x6a7360, 
    moof_offset=<optimized out>, compressed_diff=<optimized out>, cumulated_offset=<optimized out>, cumulated_offset@entry=0x7fffffffa8d8)
    at  /benchmark/gpac/src/isomedia/track.c:1248
#3  0x00007ffff747073c in MergeFragment (moof=0x6a7360, mov=mov@entry=0x6c1220) at  /benchmark/gpac/src/isomedia/isom_intern.c:92
#4  0x00007ffff7473529 in gf_isom_parse_movie_boxes_internal (mov=0x6c1220, boxType=0x0, bytesMissing=0x7fffffffa9b8, progressive_mode=GF_FALSE)
    at  /benchmark/gpac/src/isomedia/isom_intern.c:736
#5  gf_isom_parse_movie_boxes (mov=mov@entry=0x6c1220, boxType=boxType@entry=0x0, bytesMissing=bytesMissing@entry=0x7fffffffa9b8, 
    progressive_mode=progressive_mode@entry=GF_FALSE) at  /benchmark/gpac/src/isomedia/isom_intern.c:897
#6  0x00007ffff7474361 in gf_isom_open_file (
    fileName=0x7fffffffe5a5 " /testoutput/mp4hint-1/default/crashes/id:000000,sig:11,src:000992,time:15923297,execs:478509,op:havoc,rep:2", 
    OpenMode=GF_ISOM_OPEN_EDIT, tmp_dir=<optimized out>) at  /benchmark/gpac/src/isomedia/isom_intern.c:1023
#7  0x0000000000423593 in mp4box_main (argc=3, argv=0x7fffffffe2f8) at  /benchmark/gpac/applications/mp4box/mp4box.c:6297
#8  0x00007ffff6f2c083 in __libc_start_main (main=0x42a530 <main>, argc=3, argv=0x7fffffffe2f8, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffffffe2e8) at ../csu/libc-start.c:308
#9  0x0000000000410e5e in _start ()
~~~~


Detailed guidelines: http://gpac.io/bug-reporting/

--- end body ---
