Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a memory leak defect at line 786 in the file /php-src/ext/phar/stream.c. #15028

Closed
LuMingYinDetect opened this issue Jul 19, 2024 · 0 comments

Comments

@LuMingYinDetect
Copy link

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

nielsdos added a commit to nielsdos/php-src that referenced this issue Jul 19, 2024
@nielsdos nielsdos linked a pull request Jul 19, 2024 that will close this issue
nielsdos added a commit that referenced this issue Jul 19, 2024
* PHP-8.2:
  Fix GH-15028: Memory leak in ext/phar/stream.c
  Fix GH-15023: Memory leak in Zend/zend_ini.c
  Fix GH-15020: Memory leak in Zend/Optimizer/escape_analysis.c
nielsdos added a commit that referenced this issue Jul 19, 2024
* PHP-8.3:
  Fix GH-15028: Memory leak in ext/phar/stream.c
  Fix GH-15023: Memory leak in Zend/zend_ini.c
  Fix GH-15020: Memory leak in Zend/Optimizer/escape_analysis.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants