Skip to content

Structure.clear() should invoke ensureAllocated() #107

@cowwoc

Description

@cowwoc

Structure.clear() should invoke ensureAllocated() before accessing "memory". Given:

public class Foo extends Structure
{
  public volatile Pointer one;

  public Foo()
  {
    setFieldOrder(new String[]{"one"});
    clear();
  }
}

What will happen is:

  1. Structure initializes memory to a AutoAllocated buffer
  2. setFieldOrder() sets memory to null
  3. clear() uses memory before ensuring it is allocated, throwing NullPointerException

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