Curl POST emalloc leak?

From: Date: Sat, 17 May 2008 07:04:49 +0000
Subject: Curl POST emalloc leak?
Groups: php.internals 
Request: Send a blank email to internals+get-37692@lists.php.net to get a copy of this message
Can someone spot why this code (tested in both 5.2.5 and 5.3) <?php function curl($post) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "www.fdhfkdsslak.bogus"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if($post) {
    curl_setopt($ch, CURLOPT_POST, 1);
    for($args='',$i=0;$i<75;$i++) $args .= "a=$i&";
    curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
    unset($args);
} curl_exec($ch); curl_close($ch); } echo "start ".memory_get_usage()."\n"; for($i=0;$i<10;$i++) { curl(0); echo "GET ".memory_get_usage()."\n"; } for($i=0;$i<10;$i++) { curl(1); echo "POST ".memory_get_usage()."\n"; } ?> outputs: start 326616 GET 327256 GET 327276 GET 327276 GET 327276 GET 327276 GET 327276 GET 327276 GET 327276 GET 327276 GET 327276 POST 327516 POST 327588 POST 327652 POST 327712 POST 327892 POST 328064 POST 328228 POST 328384 POST 328528 POST 328628 The leak size isn't constant even though my post data size is constant, and the returned data (a dns error, presumably) is the same. Seems like there is something weird in our postfield handling code in the curl extension. Note also that it stabilizes somehow, although this is an extremely simplified version of a long-running command-line script that seems to grow on each post with wildly varying post data. -Rasmus

« previous php.internals (#37692) next »