Skip to content

Commit

Permalink
Fixed additional deallocation errors #520
Browse files Browse the repository at this point in the history
  • Loading branch information
emcconville committed Feb 24, 2021
1 parent 165d3c5 commit e70e73c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Unreleased.
- Added :meth:`Image.get_image_distortion() <wand.image.BaseImage.get_image_distortion>` method.
- Fixed `QuantumType` allocation for 32-bit architectures using HDRI. [:issue:`518`]
- Fixed `MagickSizeType` allocation for :meth:`ResourceLimits.set_resource_limit() <wand.resource.ResourceLimits.set_resource_limit>` and segfault with ``armv7l`` architecture. [:issue:`520`]
- Fixed :class:`~wand.color.Color` deallocation error on 32-bit architectures.
- [TEST] Deprecated PDF format from test assets.
- [TEST] Deprecated :class:`~wand.drawing.Drawing` text ``fx_wand`` fixture to improve parallel CI testing.
- [TEST] Marked all ImageMagick-7 features skipped when running test suite with ImageMagick-6. [:issue:`522`]
Expand Down
2 changes: 1 addition & 1 deletion tests/image_methods_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_caption(fx_asset):
)


def test_caption_without_font(fx_asset):
def test_caption_without_font():
with Image(width=144, height=192, background=Color('#1e50a2')) as img:
with raises(TypeError):
img.caption(
Expand Down
7 changes: 3 additions & 4 deletions wand/cdefs/wandtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""
import ctypes
import os
import platform
import sys

__all__ = ('c_magick_real_t', 'c_magick_size_t', 'c_ssize_t')
Expand Down Expand Up @@ -37,9 +36,9 @@

# FIXME: Might need to rewrite to check against c_void_p size;
# like `c_ssize_t` above, and not against window platform.
if sys.maxsize > 2**32:
if ctypes.sizeof(ctypes.c_size_t) == 8:
c_magick_size_t = ctypes.c_size_t
elif platform.system() == "Windows":
elif ctypes.sizeof(ctypes.c_ulonglong) == 8:
c_magick_size_t = ctypes.c_ulonglong
else:
c_magick_size_t = ctypes.c_size_t
c_magick_size_t = ctypes.c_uint64
4 changes: 3 additions & 1 deletion wand/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3214,9 +3214,11 @@ def caption(self, text, left=0, top=0, width=None, height=None, font=None,
height = self.height - top
else:
assertions.assert_integer(height=height)
if not font:
if font is None:
try:
font = self.font
if font is None:
raise TypeError()
except TypeError:
raise TypeError('font must be specified or existing in image')
with Image() as textboard:
Expand Down

0 comments on commit e70e73c

Please sign in to comment.