Changeset 5474


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

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

Location:
anuga_core/source/anuga/shallow_water
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r5473 r5474  
    50615061        reference_header_split = reference_header.split(',')
    50625062        for i in range(3):
    5063             if not file_header[i] == reference_header_split[i]:
     5063            if not file_header[i].strip() == reference_header_split[i].strip():
    50645064                msg = 'File must contain header: '+reference_header+'\n'
    50655065                raise Exception, msg
  • 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.