Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-820

Potential null pointer dereference in Main

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Incomplete
    • Affects Version/s: 1.7
    • Fix Version/s: None
    • Component/s: SVG Viewer
    • Labels:
      None
    • Environment:
      Operating System: Windows XP
      Platform: PC

      Description

      Starting at line 299 in org.apache.batik.apps.svgbrowser.Main() is the following code:

      JSVGViewerFrame relativeTo =
      viewerFrames.isEmpty()
      ? null
      : (JSVGViewerFrame) viewerFrames.get(0);
      AboutDialog dlg = new AboutDialog(relativeTo);
      // Work around pack() bug on some platforms
      dlg.setSize(dlg.getPreferredSize());
      dlg.setLocationRelativeTo(relativeTo);

      relativeTo may be set to null. This will later get passed do setLocationRelativeTo(). In AboutDlg's overridden version of this method the parameter is unconditionally dereferenced, which could cause a null pointer exception.

      AboutDlg.setLocationRelativeTo() should probably be changed to accept a null value to maintain the contract set by AboutDlg's parent JWindow.

      This was detected by FindBugs.

        Attachments

          Activity

            People

            • Assignee:
              batik-dev@xmlgraphics.apache.org Batik Developer's Mailing list
              Reporter:
              ddillard David Dillard
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: