Skip to content

Latent NPE in OverUnderBox #99

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);
  }

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