## 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/13644155/PoC.zip)
## Expected behavior 
Print error or warning messages handled within swftophp.
## Current behavior
```
header indicates a filesize of 50529130 but filesize is 134
<?php
$m = new SWFMovie(10);

ming_setscale(1.0);
$m->setRate(7.035156);
$m->setDimension(0, 0);
$m->setFrames(1799);
 Stream out of sync after parse of blocktype 11 (SWF_DEFINETEXT). 75 but expecting 71.

/* SWF_DEFINETEXT */
$character775 = new SWFText(1);
$character775->setColor(0xb3, 0x97, 0x82);
$character775->moveTo(-26729, 16383);
outputSWF_TEXT_RECORD: can't process text record: fonts information list is NULL
$character775->addString("X");
 Stream out of sync after parse of blocktype 28 (SWF_REMOVEOBJECT2). 75 but expecting 83.

/* SWF_REMOVEOBJECT2 */
$m->remove($i1799);
sudden file end: read failed @85 fileSize 134, request 56

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

0000: 07 07 07 07 ff 7f 39 05  55 02 07 07 07 05 05 05    .....9. U.......
0010: 0a f5 06 0a 0a 27 7a 51  5e 07 01 01 fd 05 05 05    .....'zQ ^.......
0020: 23 46 10 00 0a 07 07 07  07 07 07 05 05 05 23 46    #F...... ......#F
0030: 10                                                 .





	header('Content-type: application/x-shockwave-flash');
$m->output(9);
?>

=================================================================
==1402273==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7fb3260b4c38 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
    #1 0x5639766f3f84 in parseSWF_DEFINETEXT (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4af84)
    #2 0x5639766cbee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #3 0x5639766cb3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #4 0x5639766cbc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #5 0x7fb325c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 240 byte(s) in 1 object(s) allocated from:
    #0 0x7fb3260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x5639766df499 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36499)
    #2 0x5639766f40d9 in parseSWF_DEFINETEXT (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b0d9)
    #3 0x5639766cbee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #4 0x5639766cb3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #5 0x5639766cbc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #6 0x7fb325c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 120 byte(s) in 15 object(s) allocated from:
    #0 0x7fb3260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x5639766decca in parseSWF_GLYPHENTRY (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x35cca)
    #2 0x5639766df528 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36528)
    #3 0x5639766f40d9 in parseSWF_DEFINETEXT (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b0d9)
    #4 0x5639766cbee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #5 0x5639766cb3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #6 0x5639766cbc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #7 0x7fb325c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 120 byte(s) in 15 object(s) allocated from:
    #0 0x7fb3260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x5639766dead1 in parseSWF_GLYPHENTRY (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x35ad1)
    #2 0x5639766df528 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36528)
    #3 0x5639766f40d9 in parseSWF_DEFINETEXT (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b0d9)
    #4 0x5639766cbee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #5 0x5639766cb3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #6 0x5639766cbc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #7 0x7fb325c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: 528 byte(s) leaked in 32 allocation(s).
```
Memory leaks in parseSWF_DEFINETEXT
This is a GitHub Issue
repo:libming
owner:libming
Title : Memory leaks in parseSWF_DEFINETEXT
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/13644155/PoC.zip)
## Expected behavior 
Print error or warning messages handled within swftophp.
## Current behavior
```
header indicates a filesize of 50529130 but filesize is 134
<?php
$m = new SWFMovie(10);

ming_setscale(1.0);
$m->setRate(7.035156);
$m->setDimension(0, 0);
$m->setFrames(1799);
 Stream out of sync after parse of blocktype 11 (SWF_DEFINETEXT). 75 but expecting 71.

/* SWF_DEFINETEXT */
$character775 = new SWFText(1);
$character775->setColor(0xb3, 0x97, 0x82);
$character775->moveTo(-26729, 16383);
outputSWF_TEXT_RECORD: can't process text record: fonts information list is NULL
$character775->addString("X");
 Stream out of sync after parse of blocktype 28 (SWF_REMOVEOBJECT2). 75 but expecting 83.

/* SWF_REMOVEOBJECT2 */
$m->remove($i1799);
sudden file end: read failed @85 fileSize 134, request 56

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

0000: 07 07 07 07 ff 7f 39 05  55 02 07 07 07 05 05 05    .....9. U.......
0010: 0a f5 06 0a 0a 27 7a 51  5e 07 01 01 fd 05 05 05    .....'zQ ^.......
0020: 23 46 10 00 0a 07 07 07  07 07 07 05 05 05 23 46    #F...... ......#F
0030: 10                                                 .





	header('Content-type: application/x-shockwave-flash');
$m->output(9);
?>

=================================================================
==1402273==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7fb3260b4c38 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
    #1 0x5639766f3f84 in parseSWF_DEFINETEXT (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4af84)
    #2 0x5639766cbee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #3 0x5639766cb3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #4 0x5639766cbc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #5 0x7fb325c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 240 byte(s) in 1 object(s) allocated from:
    #0 0x7fb3260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x5639766df499 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36499)
    #2 0x5639766f40d9 in parseSWF_DEFINETEXT (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b0d9)
    #3 0x5639766cbee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #4 0x5639766cb3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #5 0x5639766cbc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #6 0x7fb325c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 120 byte(s) in 15 object(s) allocated from:
    #0 0x7fb3260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x5639766decca in parseSWF_GLYPHENTRY (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x35cca)
    #2 0x5639766df528 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36528)
    #3 0x5639766f40d9 in parseSWF_DEFINETEXT (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b0d9)
    #4 0x5639766cbee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #5 0x5639766cb3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #6 0x5639766cbc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #7 0x7fb325c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Indirect leak of 120 byte(s) in 15 object(s) allocated from:
    #0 0x7fb3260b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x5639766dead1 in parseSWF_GLYPHENTRY (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x35ad1)
    #2 0x5639766df528 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36528)
    #3 0x5639766f40d9 in parseSWF_DEFINETEXT (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b0d9)
    #4 0x5639766cbee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #5 0x5639766cb3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #6 0x5639766cbc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #7 0x7fb325c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: 528 byte(s) leaked in 32 allocation(s).
```
--- end body ---

The issue describes memory leaks in the `parseSWF_DEFINETEXT` function of the libming library. The leaks occur when processing SWF files, specifically when handling text records and glyph entries. This can lead to increased memory usage over time, potentially causing performance degradation or crashes if the application runs for an extended period without proper memory management. The reported leaks are detected by AddressSanitizer, indicating that allocated memory is not being freed appropriately after use.