php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44875 Memory leak in addcslashes
Submitted: 2008-04-30 20:10 UTC Modified: 2008-05-01 03:07 UTC
From: hrichter at udec dot cl Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.5 OS: Linux 2.6.9-5.EL
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hrichter at udec dot cl
New email:
PHP Version: OS:

 

 [2008-04-30 20:10 UTC] hrichter at udec dot cl
Description:
------------
The function addcslashes doesn't free memory when its first argument is longer than 4


CONFIGURE LINE:
./configure --prefix=/opt/lampp --with-apxs2=/opt/lampp/bin/apxs --with-config-file-path=/opt/lampp/etc --with-mysql=/opt/lampp --enable-inline-optimization --disable-debug --enable-bcmath --enable-calendar --enable-ctype --enable-dbase --enable-discard-path --enable-exif --enable-filepro --enable-force-cgi-redirect --enable-ftp --enable-gd-imgstrttf --enable-gd-native-ttf --with-ttf --enable-magic-quotes --enable-memory-limit --enable-shmop --enable-sigchild --enable-sysvsem --enable-sysvshm --enable-track-vars --enable-trans-sid --enable-wddx --enable-yp --with-ftp --with-gdbm=/opt/lampp --with-jpeg-dir=/opt/lampp --with-png-dir=/opt/lampp --with-freetype-dir=/opt/lampp --without-xpm --with-zlib=yes --with-zlib-dir=/opt/lampp --with-openssl=/opt/lampp --with-expat-dir=/opt/lampp --enable-xslt=/opt/lampp --with-xsl=/opt/lampp --with-dom=/opt/lampp --with-ldap=/opt/lampp --with-ncurses=/opt/lampp --with-gd --with-imap-dir=/opt/lampp --with-imap-ssl --with-imap=/opt/lampp --with-gettext=/opt/lampp --with-mssql=/opt/lampp --with-sybase=/opt/lampp --with-interbase=shared,/opt/interbase --with-mysql-sock=/opt/lampp/var/mysql/mysql.sock --with-oci8=shared,instantclient,/opt/lampp/lib/instantclient --with-mcrypt=/opt/lampp --with-mhash=/opt/lampp --enable-sockets --enable-mbstring=all --with-curl=/opt/lampp --enable-mbregex --enable-zend-multibyte --enable-exif --with-bz2=/opt/lampp --with-sqlite=shared,/opt/lampp --with-libxml-dir=/opt/lampp --enable-soap --enable-pcntl --with-mysqli=/opt/lampp/bin/mysql_config --with-mime-magic --with-pgsql=shared,/opt/lampp/postgresql --with-iconv --enable-dio --with-pdo-mysql=/opt/lampp --with-pdo-pgsql=/opt/lampp/postgresql --with-pdo-sqlite --with-ming=shared,/opt/lampp

Reproduce code:
---------------
for($i=0 ; $i<5000 ; ++$i){
	addcslashes("12345","'") ;
	echo memory_get_usage(),"<br>\n" ;
}


Expected result:
----------------
The memory usage should be the same in every iteration.

Actual result:
--------------
The memory usage keeps growing and growing up to a certain maximum which depends on the length of the first argument of addcslashes.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-01 02:38 UTC] felipe@php.net
There is no mem. leak.

Says the documentation:

int memory_get_usage ([ bool $real_usage ] )

real_usage -- Set this to TRUE to get the real size of memory allocated from system. If not set or FALSE only the memory used by emalloc() is reported.

Using that parameter you will see what you expect. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 17:01:34 2024 UTC