File tree Expand file tree Collapse file tree
pxr/imaging/plugin/hioOpenEXR/OpenEXR/OpenEXRCore Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -390,13 +390,13 @@ compress_b44_impl (exr_encode_pipeline_t* encode, int flat_field)
390390 // rightmost column and the bottom row.
391391 //
392392 uint16_t * row0 , * row1 , * row2 , * row3 ;
393+ /* row offset in elements: use uint64_t so y*nx cannot overflow int */
394+ uint64_t row_off = (uint64_t ) (y ) * (uint64_t ) (nx );
393395
394- row0 = (uint16_t * ) scratch ;
395- row0 += y * nx ;
396-
397- row1 = row0 + nx ;
398- row2 = row1 + nx ;
399- row3 = row2 + nx ;
396+ row0 = (uint16_t * ) scratch + row_off ;
397+ row1 = row0 + (uint64_t ) nx ;
398+ row2 = row1 + (uint64_t ) nx ;
399+ row3 = row2 + (uint64_t ) nx ;
400400
401401 if (y + 3 >= ny )
402402 {
@@ -512,11 +512,12 @@ uncompress_b44_impl (
512512
513513 for (int y = 0 ; y < ny ; y += 4 )
514514 {
515- row0 = (uint16_t * ) scratch ;
516- row0 += y * nx ;
517- row1 = row0 + nx ;
518- row2 = row1 + nx ;
519- row3 = row2 + nx ;
515+ /* row offset in elements: use uint64_t so y*nx cannot overflow int */
516+ uint64_t row_off = (uint64_t ) (y ) * (uint64_t ) (nx );
517+ row0 = (uint16_t * ) scratch + row_off ;
518+ row1 = row0 + (uint64_t ) nx ;
519+ row2 = row1 + (uint64_t ) nx ;
520+ row3 = row2 + (uint64_t ) nx ;
520521 for (int x = 0 ; x < nx ; x += 4 )
521522 {
522523 if (bIn + 3 > comp_buf_size ) return EXR_ERR_OUT_OF_MEMORY ;
You can’t perform that action at this time.
0 commit comments