Skip to content

Latent NPE in OverUnderBox #99

@ghost

Description

IntelliJ IDEA shows that the following line has a potential fault (script can be null and subsequently dereferenced):

+ (!over && script != null ? script.height + script.depth + kern : 0);

Whether that fault is ever realized I haven't explored. Here's the fix I added to KeenTeX:

  public OverUnderBox( Box b, Box d, Box script, float kern, boolean over ) {
    base = b;
    del = d;
    this.script = script;
    this.kern = kern;
    this.over = over;

    // Kerned height.
    final var kh = script == null ? 0 : script.height + script.depth + kern;

    // calculate metrics of the box
    width = b.getWidth();
    height = b.height
      + (over ? d.getWidth() : 0)
      + (over && script != null ? kh : 0);
    depth = b.depth
      + (over ? 0 : d.getWidth())
      + (!over && script == null ? 0 : kh);
  }

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