Skip to content

ObjectD opCast fails when casting from null #241

@gnunn1

Description

@gnunn1

I have some code in tilix that loops through parents looking for specific widget, at one point it hits the following line:

parent = cast(Container) parent.getParent();

This results in a segmentation fault when parent.getParent() returns null. Should opCast be smart enough to check for null and then just short circuit the method and return null?

Right now I can protect against it using a null check:

                if (parent.getParent() !is null)
                    parent = cast(Container) parent.getParent();
                else
                    parent = null;

I think the change in opCast was introduced in January, I'm not sure the feature this is tied too is used overly much hence why it may have escaped detection until now.

The original tilix issue is here: gnunn1/tilix#1373

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions