BitOne / php-meminfo

PHP extension to get insight about memory usage
MIT License
1.08k stars 78 forks source link

meminfo_escape_for_json memory leak #30

Closed dhopkalo closed 6 years ago

dhopkalo commented 8 years ago

Hello,

char * meminfo_escape_for_json(const char *s)
{
    int new_str_len;
    char *s1;

    s1 = php_str_to_str(s, strlen(s), "\\", 1, "\\\\", 2, &new_str_len);

    return  php_str_to_str(s1, strlen(s1), "\"", 1, "\\\"", 2, &new_str_len);
}

php_str_to_str allocates a new char * in memory that doesn't clear after.

pls see my tests that determine this problem:

27

and my solution to it

28

Thanks.

BitOne commented 6 years ago

Thanks, your solution has been merged and applied at other places too ;)