Remove potential access to NULL pointer.
authorMario de Sousa <msousa@fe.up.pt>
Tue, 12 Jun 2012 17:12:09 +0100
changeset 585 be7330d9b65c
parent 584 f95d6561d439
child 586 b602f0459f17
Remove potential access to NULL pointer.
stage3/array_range_check.cc
--- a/stage3/array_range_check.cc	Tue Jun 12 17:07:40 2012 +0100
+++ b/stage3/array_range_check.cc	Tue Jun 12 17:12:09 2012 +0100
@@ -106,6 +106,9 @@
   array_dimension_iterator_c array_dimension_iterator(var_decl);
   for (int i =  0; i < l->n; i++) {
     subrange_c *dimension = array_dimension_iterator.next();
+    /* mismatch between number of indexes/subscripts. This error will be caught in check_dimension_count() so we ignore it. */
+    if (NULL == dimension) 
+      return;
     
     if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE( int64, dimension->lower_limit))
       if ( GET_CVALUE( int64, l->elements[i])   <  GET_CVALUE( int64, dimension->lower_limit))