Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latent NPE in OverUnderBox #99

Open
ghost opened this issue Dec 24, 2022 · 0 comments
Open

Latent NPE in OverUnderBox #99

ghost opened this issue Dec 24, 2022 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 24, 2022

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);
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants