patch: info.c mem leak fixes
| From: | Rob Richards | Date: | Fri, 30 May 2003 09:41:41 +0000 |
| Subject: | patch: info.c mem leak fixes | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-2088@lists.php.net to get a copy of this message | ||
Can someone take a look at this and commit if no problems?
Fixes a few memory leaks in info.c
Thanks,
Rob
rrichards@ctindustries.net
Index: info.c =================================================================== RCS file: /repository/php4/ext/standard/info.c,v retrieving revision 1.235 diff -u -r1.235 info.c --- info.c 19 Apr 2003 17:40:19 -0000 1.235 +++ info.c 30 May 2003 09:18:58 -0000 @@ -383,7 +383,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) { char **env, *tmp1, *tmp2; - char *php_uname; + char *php_uname, *logo_guid; int expose_php = INI_INT("expose_php"); if (!sapi_module.phpinfo_as_text) { @@ -408,7 +408,9 @@ PUTS(SG(request_info).request_uri); } PUTS("?="); - PUTS(php_logo_guid()); + logo_guid = php_logo_guid(); + PUTS(logo_guid); + efree(logo_guid); PUTS("\" alt=\"PHP Logo\" /></a>"); } @@ -949,12 +951,15 @@ Return the special ID used to request the PHP logo in phpinfo screens*/ PHP_FUNCTION(php_logo_guid) { + char *logo_guid; if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - RETURN_STRING(php_logo_guid(), 1); + logo_guid = php_logo_guid(); + RETVAL_STRING(logo_guid, 1); + efree(logo_guid); } /* }}} */ @@ -1016,12 +1021,15 @@ Return information about the system PHP was built on */ PHP_FUNCTION(php_uname) { - char *mode = "a"; + char *mode = "a", *php_uname; int modelen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &mode, &modelen) == FAILURE) { return; } - RETURN_STRING(php_get_uname(*mode), 0); + + php_uname = php_get_uname(*mode); + RETVAL_STRING(php_uname, 1); + efree(php_uname); } /* }}} */
Index: info.c =================================================================== RCS file: /repository/php4/ext/standard/info.c,v retrieving revision 1.235 diff -u -r1.235 info.c --- info.c 19 Apr 2003 17:40:19 -0000 1.235 +++ info.c 30 May 2003 09:18:58 -0000 @@ -383,7 +383,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) { char **env, *tmp1, *tmp2; - char *php_uname; + char *php_uname, *logo_guid; int expose_php = INI_INT("expose_php"); if (!sapi_module.phpinfo_as_text) { @@ -408,7 +408,9 @@ PUTS(SG(request_info).request_uri); } PUTS("?="); - PUTS(php_logo_guid()); + logo_guid = php_logo_guid(); + PUTS(logo_guid); + efree(logo_guid); PUTS("\" alt=\"PHP Logo\" /></a>"); } @@ -949,12 +951,15 @@ Return the special ID used to request the PHP logo in phpinfo screens*/ PHP_FUNCTION(php_logo_guid) { + char *logo_guid; if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - RETURN_STRING(php_logo_guid(), 1); + logo_guid = php_logo_guid(); + RETVAL_STRING(logo_guid, 1); + efree(logo_guid); } /* }}} */ @@ -1016,12 +1021,15 @@ Return information about the system PHP was built on */ PHP_FUNCTION(php_uname) { - char *mode = "a"; + char *mode = "a", *php_uname; int modelen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &mode, &modelen) == FAILURE) { return; } - RETURN_STRING(php_get_uname(*mode), 0); + + php_uname = php_get_uname(*mode); + RETVAL_STRING(php_uname, 1); + efree(php_uname); } /* }}} */