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

Potential null pointer dereference in Main

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Resolution: Incomplete
    • 1.7
    • None
    • SVG Viewer
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: