diff options
Diffstat (limited to 'ext/gd/gd.c')
| -rw-r--r-- | ext/gd/gd.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 9375aeee1e..c7c6fe3fae 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -1444,6 +1444,7 @@ PHP_FUNCTION(imagesetstyle) gdImagePtr im; int *stylearr; int index = 0; + uint32_t num_styles; if (zend_parse_parameters(ZEND_NUM_ARGS(), "ra", &IM, &styles) == FAILURE) { return; @@ -1453,8 +1454,14 @@ PHP_FUNCTION(imagesetstyle) RETURN_FALSE; } + num_styles = zend_hash_num_elements(Z_ARRVAL_P(styles)); + if (num_styles == 0) { + php_error_docref(NULL, E_WARNING, "styles array must not be empty"); + RETURN_FALSE; + } + /* copy the style values in the stylearr */ - stylearr = safe_emalloc(sizeof(int), zend_hash_num_elements(Z_ARRVAL_P(styles)), 0); + stylearr = safe_emalloc(sizeof(int), num_styles, 0); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(styles), item) { stylearr[index++] = zval_get_long(item); |
