## Environment
Ubuntu 22.04.3 LTS
## Compiler
clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
## Step to reproduce
```cd libming 
./autogen.sh
./configure --disable-shared --disable-freetype
cd util
./swftophp <PoC file>
```
## Contents of PoC file
```
Unzip the file below.
```
[PoC.zip](https://github.com/libming/libming/files/13632099/PoC.zip)
## Expected behavior 
Print error or warning messages handled within swftophp.
## Current behavior
```
header indicates a filesize of 1785351530 but filesize is 167
<?php
$m = new SWFMovie(10);

ming_setscale(1.0);
$m->setRate(106.039062);
$m->setDimension(-5236, -4562);

/* Note: xMin and/or yMin are not 0! */

$m->setFrames(20817);
/*Unknown block type 325*/
Stream out of sync after parse of blocktype 33 (SWF_DEFINETEXT2). 68 but expecting 83.

/* SWF_DEFINETEXT2 */
$character2056 = new SWFText(2);
$character2056->setColor(0x07, 0x08, 0x08, 0x08);
$character2056->moveTo(2056, 2056);
outputSWF_TEXT_RECORD: can't process text record: fonts information list is NULL
$character2056->addString("X");
Stream out of sync after parse of blocktype 0 (SWF_END). 85 but expecting 93.

/* SWF_END */

extra garbage (i.e., we messed up in main):

0000: 08 08 08 08 08 08 08 08  08 08 08 08 6a 6a 6a 6a    ........ ....jjjj
0010: 6a 6a 6a 6a 6a 6a 6a 6a  6a 6a 51 51 51 08 08 08    jjjjjjjj jjQQQ...
0020: 08 6a 51 51 51 57 53 20  6a 6a 00 08 08 6a 51 51    .jQQQWS  jj...jQQ
0030: 51 51 51 51 51 54 ba ba  ba ba ba ba ba ba ba ba    QQQQQT.. ........
0040: ba ba ba ba ba ba ba ba  ba ba ba ba ba ba ba ba    ........ ........
0050: 6a 6a                                              jj

header('Content-type: application/x-shockwave-flash');

$m->output(9);
?>

=================================================================
==1320194==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 48 byte(s) in 1 object(s) allocated from:
#0 0x7ff5260b4c38 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
#1 0x55c869c5f41c in parseSWF_DEFINETEXT2 (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b41c)
#2 0x55c869c36ee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
#3 0x55c869c363ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
#4 0x55c869c36c3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
#5 0x7ff525c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Direct leak of 17 byte(s) in 1 object(s) allocated from:
#0 0x7ff5260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55c869c6bf17 in readBytes (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x57f17)
#2 0x55c869c6b509 in parseSWF_UNKNOWNBLOCK (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x57509)
#3 0x55c869c36f0a in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22f0a)
#4 0x55c869c363ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
#5 0x55c869c36c3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
#6 0x7ff525c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 128 byte(s) in 1 object(s) allocated from:
#0 0x7ff5260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55c869c4a499 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36499)
#2 0x55c869c5f571 in parseSWF_DEFINETEXT2 (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b571)
#3 0x55c869c36ee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
#4 0x55c869c363ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
#5 0x55c869c36c3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
#6 0x7ff525c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 64 byte(s) in 8 object(s) allocated from:
#0 0x7ff5260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55c869c49cca in parseSWF_GLYPHENTRY (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x35cca)
#2 0x55c869c4a528 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36528)
#3 0x55c869c5f571 in parseSWF_DEFINETEXT2 (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b571)
#4 0x55c869c36ee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
#5 0x55c869c363ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
#6 0x55c869c36c3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
#7 0x7ff525c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 64 byte(s) in 8 object(s) allocated from:
#0 0x7ff5260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55c869c49ad1 in parseSWF_GLYPHENTRY (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x35ad1)
#2 0x55c869c4a528 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36528)
#3 0x55c869c5f571 in parseSWF_DEFINETEXT2 (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b571)
#4 0x55c869c36ee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
#5 0x55c869c363ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
#6 0x55c869c36c3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
#7 0x7ff525c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: 321 byte(s) leaked in 19 allocation(s).
```
Memory leaks in parseSWF_DEFINETEXT2
This is a GitHub Issue
repo:libming
owner:libming
Title : Memory leaks in parseSWF_DEFINETEXT2
Issue date:

--- start body ---
## Environment
Ubuntu 22.04.3 LTS
## Compiler
clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
## Step to reproduce
```cd libming 
./autogen.sh
./configure --disable-shared --disable-freetype
cd util
./swftophp <PoC file>
```
## Contents of PoC file
```
Unzip the file below.
```
[PoC.zip](https://github.com/libming/libming/files/13632099/PoC.zip)
## Expected behavior 
Print error or warning messages handled within swftophp.
## Current behavior
```
header indicates a filesize of 1785351530 but filesize is 167
<?php
$m = new SWFMovie(10);

ming_setscale(1.0);
$m->setRate(106.039062);
$m->setDimension(-5236, -4562);

/* Note: xMin and/or yMin are not 0! */

$m->setFrames(20817);
/*Unknown block type 325*/
Stream out of sync after parse of blocktype 33 (SWF_DEFINETEXT2). 68 but expecting 83.

/* SWF_DEFINETEXT2 */
$character2056 = new SWFText(2);
$character2056->setColor(0x07, 0x08, 0x08, 0x08);
$character2056->moveTo(2056, 2056);
outputSWF_TEXT_RECORD: can't process text record: fonts information list is NULL
$character2056->addString("X");
Stream out of sync after parse of blocktype 0 (SWF_END). 85 but expecting 93.

/* SWF_END */

extra garbage (i.e., we messed up in main):

0000: 08 08 08 08 08 08 08 08  08 08 08 08 6a 6a 6a 6a    ........ ....jjjj
0010: 6a 6a 6a 6a 6a 6a 6a 6a  6a 6a 51 51 51 08 08 08    jjjjjjjj jjQQQ...
0020: 08 6a 51 51 51 57 53 20  6a 6a 00 08 08 6a 51 51    .jQQQWS  jj...jQQ
0030: 51 51 51 51 51 54 ba ba  ba ba ba ba ba ba ba ba    QQQQQT.. ........
0040: ba ba ba ba ba ba ba ba  ba ba ba ba ba ba ba ba    ........ ........
0050: 6a 6a                                              jj

header('Content-type: application/x-shockwave-flash');

$m->output(9);
?>

=================================================================
==1320194==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 48 byte(s) in 1 object(s) allocated from:
#0 0x7ff5260b4c38 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
#1 0x55c869c5f41c in parseSWF_DEFINETEXT2 (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b41c)
#2 0x55c869c36ee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
#3 0x55c869c363ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
#4 0x55c869c36c3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
#5 0x7ff525c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Direct leak of 17 byte(s) in 1 object(s) allocated from:
#0 0x7ff5260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55c869c6bf17 in readBytes (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x57f17)
#2 0x55c869c6b509 in parseSWF_UNKNOWNBLOCK (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x57509)
#3 0x55c869c36f0a in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22f0a)
#4 0x55c869c363ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
#5 0x55c869c36c3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
#6 0x7ff525c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 128 byte(s) in 1 object(s) allocated from:
#0 0x7ff5260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55c869c4a499 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36499)
#2 0x55c869c5f571 in parseSWF_DEFINETEXT2 (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b571)
#3 0x55c869c36ee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
#4 0x55c869c363ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
#5 0x55c869c36c3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
#6 0x7ff525c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 64 byte(s) in 8 object(s) allocated from:
#0 0x7ff5260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55c869c49cca in parseSWF_GLYPHENTRY (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x35cca)
#2 0x55c869c4a528 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36528)
#3 0x55c869c5f571 in parseSWF_DEFINETEXT2 (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b571)
#4 0x55c869c36ee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
#5 0x55c869c363ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
#6 0x55c869c36c3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
#7 0x7ff525c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 64 byte(s) in 8 object(s) allocated from:
#0 0x7ff5260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55c869c49ad1 in parseSWF_GLYPHENTRY (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x35ad1)
#2 0x55c869c4a528 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36528)
#3 0x55c869c5f571 in parseSWF_DEFINETEXT2 (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b571)
#4 0x55c869c36ee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
#5 0x55c869c363ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
#6 0x55c869c36c3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
#7 0x7ff525c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: 321 byte(s) leaked in 19 allocation(s).
```
--- end body ---
