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

The file /php-src/Zend/Optimizer/escape_analysis.c has a memory leak defect at line 417 #15020

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

Comments

@LuMingYinDetect
Copy link

Description

In the file /php-src/Zend/Optimizer/escape_analysis.c, at line 387, a pointer variable named ees is defined. At line 411, this variable allocates a dynamic memory area using the do_alloca function. If the conditional statement at line 412 evaluates to false, it indicates that the dynamic memory allocation pointed to by ees was successful. However, if the conditional statement at line 416 evaluates to true, the function will return at line 417, bypassing the deallocation of the dynamic memory area pointed to by ees at line 532. This situation constitutes a memory leak, as illustrated in the diagram below:
https://github.com/LuMingYinDetect/php_defects/blob/main/php_1.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 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
@Bilge
Copy link

Bilge commented Aug 29, 2024

Is this some kind of bot?

@nielsdos
Copy link
Member

While there are certainly bots like these, I think this is a real person using static analysis, given the varying wording between the issues.

@Bilge
Copy link

Bilge commented Aug 29, 2024

Why don't we have his static analysis tools? 😆

@nielsdos
Copy link
Member

Actually, I sometimes run static analysis tools on PHP. That's how I started in my early contribution days actually.
I even experiment with my own tools on PHP.

@LuMingYinDetect
Copy link
Author

Actually, I sometimes run static analysis tools on PHP. That's how I started in my early contribution days actually.
I even experiment with my own tools on PHP.

This is a tool I improved based on the Clang Static Analyzer, and I am planning to submit a paper on it. I will open-source the tool in the paper!

@LuMingYinDetect
Copy link
Author

Why don't we have his static analysis tools? 😆

This is a tool I improved based on the Clang Static Analyzer, and I am planning to submit a paper on it. I will open-source the tool in the paper!

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.

3 participants