ext/gd create gd object with zend_object_alloc (#17823)

while at it, fix build warning "wrong" calloc arguments order
This commit is contained in:
David CARLIER 2025-02-16 00:05:37 +00:00 committed by GitHub
parent 82bdc8a2ad
commit 18df1e4783
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 5 deletions

View file

@ -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);

View file

@ -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;
}