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

ming_setscale(1.0);
$m->setRate(10.078125);
$m->setDimension(0, 0);
$m->setFrames(2560);
 Stream out of sync after parse of blocktype 33 (SWF_DEFINETEXT2). 34 but expecting 57.

/* SWF_DEFINETEXT2 */
$character21248 = new SWFText(2);
$character21248->setColor(0xff, 0xff, 0x16, 0x00);
$character21248->moveTo(0, 2570);
outputSWF_TEXT_RECORD: can't process text record: fonts information list is NULL
$character21248->addString("X");
 Stream out of sync after parse of blocktype 40 (SWF_NAMECHARACTER). 68 but expecting 69.

/* SWF_NAMECHARACTER */
sudden file end: read failed @75 fileSize 299, request 658046

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

0000: 0a 0a 01 01 01 01 01 01  aa 00 00 10 00 00 00 00    ........ ........
0010: 00 6a 01 14 01 01 1c 0a  10 13 00 00 20 18 08 08    .j...... .... ...
0020: 08 08 08 08 08 08 08 08  08 08 08 08 08 08 dc 01    ........ ........
0030: 01 0a 0a 0a 0a 00 20 18  0a 0a 0a 0a 0a 0a b8 0a    ...... . ........
0040: 0a 57 53 0a 6a 09 00 ff  ff e8 7e 0a 0a 00 0a 0a    .WS.j... ..~.....
0050: 01 01 01 01 01 01 57 53  0a 08 08 07 08 08 08 53    ......WS .......S
0060: 53 53 53 53 53 53 53 53  53 53 53 53 53 53 53 53    SSSSSSSS SSSSSSSS
0070: 53 0a 6a 09 00 ff ff f7  7e 0a 0a 00 00 12 0a 00    S.j..... ~.......
0080: 09 0a 0a 0a 0a 0a 0a 0a  0a 0a 0a 0a 0a 0a 0a 0a    ........ ........
0090: 0a 0a 0a 0a 0a 0a 0a 0a  0a 0a 0a 0a 0a 0a 0a 0a    ........ ........
00a0: 0a 0a 0a 0a 0a 0a 0a 0a  0a 0a 0a 0a 46 57 53 0a    ........ ....FWS.
00b0: 6a 01 53 07 07 07 07 07  f9 07 07 07 14 0a 0a 80    j.S..... ........
00c0: 00 00 20 4b ef 40 0a 0a  1a 09 00 20 4b 0a 2d 0a    .. K.@.. ... K.-.
00d0: 15 14 0a 0a 00 09 0a 00  00 00 ff ff 00 00 00 00    ........ ........





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

=================================================================
==1320128==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 256 byte(s) in 1 object(s) allocated from:
    #0 0x7fbc1eab4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x561f3ea42013 in readString (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x58013)
    #2 0x561f3ea378d0 in parseSWF_NAMECHARACTER (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4d8d0)
    #3 0x561f3ea0cee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #4 0x561f3ea0c3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #5 0x561f3ea0cc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #6 0x7fbc1e629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

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

Indirect leak of 1 byte(s) in 1 object(s) allocated from:
    #0 0x7fbc1eab4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x561f3ea20499 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36499)
    #2 0x561f3ea35571 in parseSWF_DEFINETEXT2 (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b571)
    #3 0x561f3ea0cee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #4 0x561f3ea0c3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #5 0x561f3ea0cc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #6 0x7fbc1e629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: 305 byte(s) leaked in 3 allocation(s).
```
## Conclusion
1. The variable returned by the `readString` function in the /util/read.c file has not been freed.
2. The `parserrec->TextRecords` variable of the `parseSWF_DEFINETEXT2` function in the /util/parser.c file has not been freed.
3. The `parserrec->Name` variable of the `parseSWF_NAMECHARACTER` function in the /util/parser.c file has not been freed.
Memory leaks in readString
This is a GitHub Issue
repo:libming
owner:libming
Title : Memory leaks in readString
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/13632064/PoC.zip)
## Expected behavior 
Print error or warning messages handled within swftophp.
## Current behavior
```
header indicates a filesize of 173212010 but filesize is 299
<?php
$m = new SWFMovie(10);

ming_setscale(1.0);
$m->setRate(10.078125);
$m->setDimension(0, 0);
$m->setFrames(2560);
 Stream out of sync after parse of blocktype 33 (SWF_DEFINETEXT2). 34 but expecting 57.

/* SWF_DEFINETEXT2 */
$character21248 = new SWFText(2);
$character21248->setColor(0xff, 0xff, 0x16, 0x00);
$character21248->moveTo(0, 2570);
outputSWF_TEXT_RECORD: can't process text record: fonts information list is NULL
$character21248->addString("X");
 Stream out of sync after parse of blocktype 40 (SWF_NAMECHARACTER). 68 but expecting 69.

/* SWF_NAMECHARACTER */
sudden file end: read failed @75 fileSize 299, request 658046

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

0000: 0a 0a 01 01 01 01 01 01  aa 00 00 10 00 00 00 00    ........ ........
0010: 00 6a 01 14 01 01 1c 0a  10 13 00 00 20 18 08 08    .j...... .... ...
0020: 08 08 08 08 08 08 08 08  08 08 08 08 08 08 dc 01    ........ ........
0030: 01 0a 0a 0a 0a 00 20 18  0a 0a 0a 0a 0a 0a b8 0a    ...... . ........
0040: 0a 57 53 0a 6a 09 00 ff  ff e8 7e 0a 0a 00 0a 0a    .WS.j... ..~.....
0050: 01 01 01 01 01 01 57 53  0a 08 08 07 08 08 08 53    ......WS .......S
0060: 53 53 53 53 53 53 53 53  53 53 53 53 53 53 53 53    SSSSSSSS SSSSSSSS
0070: 53 0a 6a 09 00 ff ff f7  7e 0a 0a 00 00 12 0a 00    S.j..... ~.......
0080: 09 0a 0a 0a 0a 0a 0a 0a  0a 0a 0a 0a 0a 0a 0a 0a    ........ ........
0090: 0a 0a 0a 0a 0a 0a 0a 0a  0a 0a 0a 0a 0a 0a 0a 0a    ........ ........
00a0: 0a 0a 0a 0a 0a 0a 0a 0a  0a 0a 0a 0a 46 57 53 0a    ........ ....FWS.
00b0: 6a 01 53 07 07 07 07 07  f9 07 07 07 14 0a 0a 80    j.S..... ........
00c0: 00 00 20 4b ef 40 0a 0a  1a 09 00 20 4b 0a 2d 0a    .. K.@.. ... K.-.
00d0: 15 14 0a 0a 00 09 0a 00  00 00 ff ff 00 00 00 00    ........ ........





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

=================================================================
==1320128==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 256 byte(s) in 1 object(s) allocated from:
    #0 0x7fbc1eab4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x561f3ea42013 in readString (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x58013)
    #2 0x561f3ea378d0 in parseSWF_NAMECHARACTER (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4d8d0)
    #3 0x561f3ea0cee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #4 0x561f3ea0c3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #5 0x561f3ea0cc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #6 0x7fbc1e629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

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

Indirect leak of 1 byte(s) in 1 object(s) allocated from:
    #0 0x7fbc1eab4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x561f3ea20499 in parseSWF_TEXTRECORD (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x36499)
    #2 0x561f3ea35571 in parseSWF_DEFINETEXT2 (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x4b571)
    #3 0x561f3ea0cee4 in blockParse (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22ee4)
    #4 0x561f3ea0c3ca in readMovie (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x223ca)
    #5 0x561f3ea0cc3d in main (/home/smb8508/Desktop/work_space/debuging/libming/util/swftophp+0x22c3d)
    #6 0x7fbc1e629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: 305 byte(s) leaked in 3 allocation(s).
```
## Conclusion
1. The variable returned by the `readString` function in the /util/read.c file has not been freed.
2. The `parserrec->TextRecords` variable of the `parseSWF_DEFINETEXT2` function in the /util/parser.c file has not been freed.
3. The `parserrec->Name` variable of the `parseSWF_NAMECHARACTER` function in the /util/parser.c file has not been freed.
--- end body ---
