Skip to content

Picture.get_paint() calls tvg_picture_get_size instead of tvg_picture_get_paint — access violation #3

@ElliotGarbus

Description

@ElliotGarbus

Overview

Picture.get_paint() contains an error that causes an immediate access violation when called. All three ctypes lines inside the method incorrectly reference tvg_picture_get_size instead of tvg_picture_get_paint.

Reproducer

import thorvg_python as tvg
engine = tvg.Engine(threads=0)
pic = tvg.Picture(engine)
svg = (
    b'<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">'
    b'<circle id="ring" r="40" cx="50" cy="50" fill="red"/>'
    b'</svg>'
)
pic.load_data(svg, 'svg', None, False)
pic.get_paint(12345)  # OSError: exception: access violation writing 0x...
Root cause
In thorvg_python/paint/picture.py, the get_paint method:

def get_paint(self, _id: int):
    self.thorvg_lib.tvg_picture_get_size.argtypes = [...]   # ← wrong
    self.thorvg_lib.tvg_picture_get_size.restype = ...      # ← wrong
    paint_struct = self.thorvg_lib.tvg_picture_get_size(    # ← wrong
        self._paint, ctypes.c_uint32(_id),
    )

Fix

Replace all three occurrences of tvg_picture_get_size with tvg_picture_get_paint.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions