php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74799 Memory leak in yaml_parse method
Submitted: 2017-06-22 15:27 UTC Modified: 2017-07-29 15:51 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: gleb dot svitelskiy at gmail dot com Assigned: bd808 (profile)
Status: Closed Package: yaml (PECL)
PHP Version: 7.1.6 OS: Debian Jessie 8.8
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gleb dot svitelskiy at gmail dot com
New email:
PHP Version: OS:

 

 [2017-06-22 15:27 UTC] gleb dot svitelskiy at gmail dot com
Description:
------------
Each yaml_parse() method call with callback parameter doesn't free allocated memory.
When script is running for a long time fatal errors occurs.
It reproduce only with callback parameter. Even with empty array.

YAML Extension version 2.0.0
LibYAML version 0.1.6

[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
yaml
zlib



Test script:
---------------
php -r '$input="array:\n  key: !callback value\n"; $iterationsNumber=10; $ndocs=0; $i=0; function callback() {return "callback value";} $baseMemory=memory_get_usage(); while ($i<$iterationsNumber) {$i++; yaml_parse($input, 0, $ndocs, ["!callback" => "callback"]);$memory=memory_get_usage();echo "Memory consumed: ".$memory." Delta: ".($memory - $baseMemory)."\n";}'


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-29 15:51 UTC] bd808@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: bd808
 [2017-07-29 15:51 UTC] bd808@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

https://github.com/php/pecl-file_formats-yaml/pull/28
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 03:01:28 2025 UTC