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

Out of bounds array access #73

Closed
cschol opened this issue Nov 6, 2022 · 1 comment
Closed

Out of bounds array access #73

cschol opened this issue Nov 6, 2022 · 1 comment

Comments

@cschol
Copy link

cschol commented Nov 6, 2022

I started running static analysis with cppcheck as part of the integration process and it found this potential out of bounds array access.

I am not holding integration, but please check it out for the next release. Thanks!

Checking Grendel.cpp ...             
32/60 files checked 34% done
GenieExpander.cpp:31:10: error: Array 'colors[4][3]' accessed at index colors[4][*], which is out of bounds. [arrayIndexOutOfBounds]
   colors[i][j]=rnd(generator);
         ^                  
GenieExpander.cpp:29:16: note: Assuming that condition 'i<=4' is not redundant
 for (int i=0;i<=4;i++)                                                                                                                                    
               ^            
GenieExpander.cpp:31:10: note: Array index out of bounds
   colors[i][j]=rnd(generator);  
         ^          
GenieExpander.cpp:343:10: error: Array 'edges[4][2]' accessed at index edges[*][3], which is out of bounds. [arrayIndexOutOfBounds]
    edges[i][n]=rdMsg->edges[i][n];                                                                                                                        
         ^                                                                                                                                                 
GenieExpander.cpp:342:18: note: Assuming that condition 'n<4' is not redundant                                                                             
   for (int n=0;n<4;n++)         
                 ^                                                                                                                                         
GenieExpander.cpp:343:10: note: Array index out of bounds
    edges[i][n]=rdMsg->edges[i][n];
         ^                                                                                                                                                 
GenieExpander.cpp:343:29: error: Array 'rdMsg->edges[4][2]' accessed at index rdMsg->edges[*][3], which is out of bounds. [arrayIndexOutOfBounds]          
    edges[i][n]=rdMsg->edges[i][n];  
                            ^
GenieExpander.cpp:342:18: note: Assuming that condition 'n<4' is not redundant                                                                             
   for (int n=0;n<4;n++)                                                                                                                                   
                 ^                                                                                                                                         
GenieExpander.cpp:343:29: note: Array index out of bounds                                                                                                  
    edges[i][n]=rdMsg->edges[i][n];                                                                                                                        
                            ^      
@kockie69
Copy link
Owner

Closing this one, as it has been fixed in the past. Let me know if there is more.

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

2 participants