diff --git a/imagickdraw_class.c b/imagickdraw_class.c index da00cbba..95cac482 100644 --- a/imagickdraw_class.c +++ b/imagickdraw_class.c @@ -336,7 +336,7 @@ PHP_METHOD(ImagickDraw, setFillColor) */ PHP_METHOD(ImagickDraw, setResolution) { - char *density, *buf = NULL; + char *buf_density = NULL; double x, y; php_imagickdraw_object *internd; DrawInfo *draw_info; @@ -348,30 +348,34 @@ PHP_METHOD(ImagickDraw, setResolution) internd = Z_IMAGICKDRAW_P(getThis()); - spprintf(&buf, 512, "%fx%f", x, y); - density = AcquireString(buf); - efree (buf); - - if (!density) { + spprintf(&buf_density, 512, "%fx%f", x, y); + if (!buf_density) { php_imagick_throw_exception(IMAGICKDRAW_CLASS, "Failed to allocate memory" TSRMLS_CC); - return; + RETURN_THROWS(); } draw_info = PeekDrawingWand(internd->drawing_wand); - draw_info->density = density; - #if MagickLibVersion >= 0x693 d_wand = AcquireDrawingWand(draw_info, NULL); #else d_wand = (DrawingWand *) DrawAllocateWand(draw_info, NULL); #endif + draw_info=DestroyDrawInfo(draw_info); if (!d_wand) { php_imagick_throw_exception(IMAGICKDRAW_CLASS, "Failed to allocate new DrawingWand structure" TSRMLS_CC); return; } + if (!DrawSetDensity(d_wand, buf_density)) { + efree (buf_density); + php_imagick_throw_exception(IMAGICKDRAW_CLASS, "Failed to SetDensity" TSRMLS_CC); + RETURN_THROWS(); + } + + efree (buf_density); + php_imagick_replace_drawingwand(internd, d_wand); RETURN_TRUE; }