Skip to content

Unsafe type assertion #772

Description

@burkeartem

In line 76 value may have type different from '*bool'.

The type assertion assumes that value is not zero and that value stores a value of type *bool, otherwise the command will cause panic. If value is checked for zero in line 73, then apparently a check for the *bool type is performed in line 76, but such a check is incorrect, because it will cause panic if the value type does not match the *bool type.

I think it would be safer to use the following construction:
if _, ok :=value.(*bool); ok { ... }

Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE.
Author A. Burke.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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