Skip to content

Commit

Permalink
ext/gd create gd object with zend_object_alloc (#17823)
Browse files Browse the repository at this point in the history
while at it, fix build warning "wrong" calloc arguments order
  • Loading branch information
devnexen authored Feb 16, 2025
1 parent 82bdc8a commit 18df1e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ PHP_GD_API gdImagePtr php_gd_libgdimageptr_from_zval_p(zval* zp)

zend_object *php_gd_image_object_create(zend_class_entry *class_type)
{
size_t block_len = sizeof(php_gd_image_object) + zend_object_properties_size(class_type);
php_gd_image_object *intern = emalloc(block_len);
memset(intern, 0, block_len);
php_gd_image_object *intern = zend_object_alloc(sizeof(php_gd_image_object), class_type);

zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
Expand Down
4 changes: 2 additions & 2 deletions ext/gd/libgd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3190,8 +3190,8 @@ int gdImagePaletteToTrueColor(gdImagePtr src)
// Note: do not revert back to gdMalloc() below ; reason here,
// due to a bug with a certain memory_limit INI value treshold,
// imagepalettetotruecolor crashes with even unrelated ZendMM allocations.
// See GH-17772 for an use case.
src->tpixels = (int **) gdCalloc(sizeof(int *), sy);
// See GH-17772 for a use case.
src->tpixels = (int **) gdCalloc(sy, sizeof(int *));
if (src->tpixels == NULL) {
return 0;
}
Expand Down

0 comments on commit 18df1e4

Please sign in to comment.