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

            ravidavi Ravi Mathur created issue -
            shughes Steven Hughes made changes -
            Field Original Value New Value
            Priority P1 [ 1 ] P2 [ 3 ]
            shughes Steven Hughes made changes -
            Fix Version/s R2019a [ 11200 ]
            shughes Steven Hughes made changes -
            Assignee Rizwan Qureshi [ rqureshi ] Darrel Conway [ djcinsb ]
            Hide
            shughes Steven Hughes added a comment -

            Because it is easy, fix it.

            Show
            shughes Steven Hughes added a comment - Because it is easy, fix it.

              People

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

                Dates

                • Created:
                  Updated: