diff --git a/envi/binary.h b/envi/binary.h index 0a0477d..3f7216f 100644 --- a/envi/binary.h +++ b/envi/binary.h @@ -99,11 +99,17 @@ public: return p; } - T * saveXY(int x, int y){ + T * saveXY(unsigned x, unsigned y){ T * px; unsigned int i; + if (x<1||x>R[0]||y<1||y>R[1]){ //make sure the sample and line number is right + cout<<"wrong page"; + getchar(); + return NULL; + } + px=(T *)malloc(R[2]*sizeof(T)); //memory allocation if (px==NULL) cout<<"memory allocation failure"; @@ -116,7 +122,6 @@ public: { file.read((char *)(px+i), sizeof(T)); file.seekg((R[1]*R[0]-1)*sizeof(T),ios::cur); //go to the next band - px[i]; } return px; -- libgit2 0.21.4