diff --git a/Modules/IO/IOMSTAR/src/otbMSTARImageIO.cxx b/Modules/IO/IOMSTAR/src/otbMSTARImageIO.cxx
index 9f4322eecd218df127644a5d65635f9274667baf..7ac218c33b3dde7341661cb4ff75d4323d138a08 100644
--- a/Modules/IO/IOMSTAR/src/otbMSTARImageIO.cxx
+++ b/Modules/IO/IOMSTAR/src/otbMSTARImageIO.cxx
@@ -705,12 +705,13 @@ float MSTARImageIO::byteswap_SR_IR(unsigned char *pointer)
 {
   float *       temp;
   unsigned char iarray[4];
-
+  void *vptr;
   iarray[0] = *(pointer + 3);
   iarray[1] = *(pointer + 2);
   iarray[2] = *(pointer + 1);
   iarray[3] = *(pointer);
-  temp    = (float *) iarray ;
+  vptr = static_cast<void*>(iarray);
+  temp = static_cast<float*>(vptr);
   return *(temp);
 }
 
@@ -718,10 +719,11 @@ unsigned short MSTARImageIO::byteswap_SUS_IUS(unsigned char *pointer)
 {
   unsigned short *temp;
   unsigned char   iarray[2];
-
+  void *vptr;
   iarray[0] = *(pointer + 1);
   iarray[1] = *(pointer);
-  temp    = (unsigned short *) iarray;
+  vptr = static_cast<void*>(iarray);
+  temp = static_cast<unsigned short*>(vptr);
   return *(temp);
 }
 
diff --git a/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.txx b/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.txx
index 8fd8030db24305299c1cc51d4ebe4504b546519d..7f9cd034e0278a3b221359e84e9d29acd5576cd3 100644
--- a/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.txx
+++ b/Modules/Registration/Stereo/include/otbAdhesionCorrectionFilter.txx
@@ -632,7 +632,7 @@ AdhesionCorrectionFilter<TImage, TMask>
               int l=-2-win;
               index2[0] = index_pos[0] + i;
               index2[1] = index_pos[1] + l;
-              while (old_maskPtr->GetPixel(index2) == 0)
+              while (old_maskPtr->GetBufferedRegion().IsInside(index2) && old_maskPtr->GetPixel(index2) == 0)
                 {
                 l++;
                 index2[1] = index_pos[1] + l;