Skip to content

Commit

Permalink
Fixed segfault when invoking Color before MagickWandGenesis. #586
Browse files Browse the repository at this point in the history
  • Loading branch information
emcconville committed Aug 3, 2022
1 parent 3523f37 commit d269eaa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changes.rst
Expand Up @@ -16,6 +16,7 @@ Unreleased.

- Updated :meth:`Image.fx() <wand.image.BaseImage.fx>` method to raise :class:`~wand.exceptions.WandRuntimeError` if ImageMagick is unable to generate an image. [:issue:`582`]
- Fixed :meth:`Image.from_array() <wand.image.Image.from_array>` classmethod to handle Numpy's strided arrays. [:issue:`582`]
- Fixed segmentation fault with ImageMagick 7.1.0-4X release. [:issue:`586`]


.. _changelog-0.6.8:
Expand Down
5 changes: 4 additions & 1 deletion wand/color.py
Expand Up @@ -10,7 +10,7 @@
from .api import library
from .cdefs.structures import MagickPixelPacket, PixelInfo
from .compat import binary, text
from .resource import Resource
from .resource import Resource, genesis
from .version import MAGICK_VERSION_NUMBER, MAGICK_HDRI, QUANTUM_DEPTH

__all__ = 'Color', 'scale_quantum_to_int8'
Expand Down Expand Up @@ -124,6 +124,9 @@ def __getinitargs__(self):

def __enter__(self):
if self.allocated < 1:
# As of 0x710, we must call MagickWandGenesis before allocate of
# Wand's Resource & ImageMagick PixelWand.
genesis()
with self.allocate():
# Initialize resource.
self.resource = library.NewPixelWand()
Expand Down

0 comments on commit d269eaa

Please sign in to comment.