summaryrefslogtreecommitdiff
path: root/ext/standard/image.c
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2014-03-06 18:30:32 +0800
committerXinchen Hui <laruence@gmail.com>2014-03-06 18:30:32 +0800
commite4f5b9ac381f0751ce769050ebf670f1988fd059 (patch)
tree73a566504d33a896fc378ebc0ef202c513c98bf0 /ext/standard/image.c
parentb2124612976bf4f3a56f43f6e78f7d11a3a28d3e (diff)
downloadphp-git-e4f5b9ac381f0751ce769050ebf670f1988fd059.tar.gz
Fixed memory leak in getimagesize
Diffstat (limited to 'ext/standard/image.c')
-rw-r--r--ext/standard/image.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/ext/standard/image.c b/ext/standard/image.c
index ce48b961f4..137f91b79f 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -1289,9 +1289,8 @@ PHPAPI int php_getimagetype(php_stream * stream, char *filetype TSRMLS_DC)
}
/* }}} */
-static void php_getimagesize_from_stream(php_stream *stream, zval **info, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
+static void php_getimagesize_from_stream(php_stream *stream, zval *info, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
{
- char *temp;
int itype = 0;
struct gfxinfo *result = NULL;
@@ -1306,7 +1305,7 @@ static void php_getimagesize_from_stream(php_stream *stream, zval **info, INTERN
break;
case IMAGE_FILETYPE_JPEG:
if (info) {
- result = php_handle_jpeg(stream, *info TSRMLS_CC);
+ result = php_handle_jpeg(stream, info TSRMLS_CC);
} else {
result = php_handle_jpeg(stream, NULL TSRMLS_CC);
}
@@ -1360,11 +1359,12 @@ static void php_getimagesize_from_stream(php_stream *stream, zval **info, INTERN
}
if (result) {
+ char temp[MAX_LENGTH_OF_LONG * 2 + sizeof("width=\"\" height=\"\"")];
array_init(return_value);
add_index_long(return_value, 0, result->width);
add_index_long(return_value, 1, result->height);
add_index_long(return_value, 2, itype);
- spprintf(&temp, 0, "width=\"%d\" height=\"%d\"", result->width, result->height);
+ snprintf(temp, sizeof(temp), "width=\"%d\" height=\"%d\"", result->width, result->height);
add_index_string(return_value, 3, temp, 0);
if (result->bits != 0) {
@@ -1385,22 +1385,22 @@ static void php_getimagesize_from_stream(php_stream *stream, zval **info, INTERN
#define FROM_PATH 1
static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) { /* {{{ */
- zval **info = NULL;
+ zval *info = NULL;
php_stream *stream = NULL;
char *input;
int input_len;
const int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argc TSRMLS_CC, "s|Z", &input, &input_len, &info) == FAILURE) {
+ if (zend_parse_parameters(argc TSRMLS_CC, "s|z", &input, &input_len, &info) == FAILURE) {
return;
}
if (argc == 2) {
- zval_dtor(*info);
- array_init(*info);
+ info = Z_REFVAL_P(info);
+ zval_dtor(info);
+ array_init(info);
}
-
if (mode == FROM_PATH) {
stream = php_stream_open_wrapper(input, "rb", STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH, NULL);
} else {