Uploaded image for project: 'GMAT'
  1. GMAT
  2. GMT-6501

GLStars constellation index out of range

    Details

      Description

      In GLStars.cpp line 489-491:

       for (int i=0;  i<=BorderGroupCount-1;  ++i)
        glDrawArrays(GL_LINE_STRIP, BorderGroup[i], BorderGroup[i+1]-BorderGroup[i]-1);
      

      Bug (Debug mode only): Bad Memory Access crash in glDrawArrays due to third argument being an uninitialized huge integer.

      Fix: The for loop test should be < (less than), not <= (less than or equal). i < BorderGroupCount-1

      Reason: BorderGroupCount is one greater than the last valid BorderGroup index, so accessing BorderGroup[i+1] when i = BorderGroupCount-1 is invalid. The current code only works in Release mode because all BorderGroup indices default to zero, which makes the last argument to glDrawArrays a negative number. This results in an ignored OpenGL error. However in Debug mode arrays are not auto-initialized, so the last argument to glDrawArrays is an undefined integer, leading to an OpenGL bad memory access crash.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: