[php-src] Issue #15028: There is a memory leak defect at line 786 in the file /php-src/ext/phar/stream.c.
| From: | LuMingYinDetect | Date: | Fri, 19 Jul 2024 12:02:53 +0000 |
| Subject: | [php-src] Issue #15028: There is a memory leak defect at line 786 in the file /php-src/ext/phar/stream.c. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247321@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/15028
Author: LuMingYinDetect
### Description
At line 746 of the file /php-src/ext/phar/stream.c, a pointer variable named resource_to is defined.
This pointer is allocated a new block of dynamic memory through the function phar_parse_url at line
772. If the if statement at line 772 evaluates to false, it indicates that the allocation of dynamic
memory for resource_to was successful. When the if statement at line 783 returns true, the function
exits at line 786. During this process, the dynamically allocated memory pointed to by resource_to,
which was neither freed like at line 791 nor used, leads to a memory leak defect, as illustrated
below:
https://github.com/LuMingYinDetect/php_defects/blob/main/php_4.png
### PHP Version
PHP 8.4.0
### Operating System
Ubuntu 22.04