Skip to content

UB in ListOf proxies #1463

Description

@Enchufa2

Another UB triggered in

CharacterVector listof_names(ListOf<NumericVector> x) {
return x.names();
}

The issue is in the definition

template <typename T>
class ListOf
: public NamesProxyPolicy<T>
, public AttributeProxyPolicy<T>
, public RObjectMethods<T>
{

Since ListOf<T> is a wrapper, it should inherit from NamesProxyPolicy<ListOf<T>> instead, etc. Otherwise, this cast produces the UB:

NamesProxy names() {
return NamesProxy( static_cast<CLASS&>(*this) ) ;
}

But then we need to avoid using methods that are not part of ListOf<T>, such as get__() and set__() (or define them). PR coming.

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