Description
A pointer variable named context is defined at line 1189 in the /php-src/ext/standard/streamsfuncs.c file. At line 1197, a new dynamic memory region is allocated for context using the php_stream_context_alloc function. If the if statement at line 1200 evaluates to true, the function will return at line 1201. In this process, the dynamic memory region pointed to by context is neither used, as it is at line 1211, nor freed, resulting in a memory leak defect, as shown in the figure below.
https://github.com/LuMingYinDetect/php_defects/blob/main/php_5.png
The defect report was generated by a static analysis tool. Although it has undergone manual review and confirmation, false positives may still occur. If you identify any false positives, please let us know. We would greatly appreciate your help!
PHP Version
PHP 8.4.4
Operating System
Ubuntu 20.04