Skip to content

Commit 17cd08e

Browse files
authored
FABio_8bit reader: Fix overflow (#5244)
The FABio_8bit writer uses amrex::Long for size, so the reader should be consistent.
1 parent 87a0cdc commit 17cd08e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Src/Base/AMReX_FArrayBox.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,8 @@ FABio_8bit::read (std::istream& is,
820820
auto *c = new unsigned char[siz];
821821

822822
Real mn, mx;
823-
for(int nbytes, k = 0; k < f.nComp(); ++k) {
823+
Long nbytes;
824+
for(int k = 0; k < f.nComp(); ++k) {
824825
is >> mn >> mx >> nbytes;
825826
BL_ASSERT(nbytes == siz);
826827
while (is.get() != '\n') {
@@ -850,7 +851,8 @@ FABio_8bit::skip (std::istream& is,
850851
const Box& bx = f.box();
851852
Long siz = bx.numPts();
852853
Real mn, mx;
853-
for(int nbytes, k = 0; k < f.nComp(); ++k) {
854+
Long nbytes;
855+
for(int k = 0; k < f.nComp(); ++k) {
854856
is >> mn >> mx >> nbytes;
855857
BL_ASSERT(nbytes == siz);
856858
while(is.get() != '\n') {
@@ -872,7 +874,8 @@ FABio_8bit::skip (std::istream& is,
872874
const Box& bx = f.box();
873875
Long siz = bx.numPts();
874876
Real mn, mx;
875-
for(int nbytes, k = 0; k < nCompToSkip; ++k) {
877+
Long nbytes;
878+
for(int k = 0; k < nCompToSkip; ++k) {
876879
is >> mn >> mx >> nbytes;
877880
BL_ASSERT(nbytes == siz);
878881
while(is.get() != '\n') {

0 commit comments

Comments
 (0)