Ignore:
Timestamp:
Jul 7, 2008, 4:03:14 PM (14 years ago)
Author:
ole
Message:

'added check to ensure that permutation indices are not out of bounds'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/urs_ext.c

    r5473 r5474  
    197197     // Specifies the gauge numbers that for which data is to be extracted
    198198     permutation_array=(PyArrayObject *) PyArray_ContiguousFromObject(permutation,PyArray_INT,1,1);
     199     N = permutation_array->dimensions[0]; //FIXME: this is overwritten below
     200     for (ista=0; ista<N; ista++){
     201       if ((int)*(long *) (permutation_array -> data+ista*permutation_array->strides[0])>=nsta0){
     202         printf("Maximum index = %d, you had %d\n",nsta0-1,(int)*(long *) (permutation_array -> data+ista*permutation_array->strides[0]));
     203         PyErr_SetString(PyExc_RuntimeError,"The permutation specified is out of bounds");
     204         return NULL;
     205       }
     206     }
    199207   }
    200208   if(permutation_array == NULL){
    201      PyErr_SetString(PyExc_RuntimeError,"ERROR: Memory for permutation_array array could not be allocated");
     209     PyErr_SetString(PyExc_RuntimeError,"Memory for permutation_array array could not be allocated");
    202210     return NULL;
    203211   }
Note: See TracChangeset for help on using the changeset viewer.