File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -177,18 +177,17 @@ internal_exr_undo_ht (
177177 if (decode->channel_count != cs_to_file_ch.size ())
178178 throw std::runtime_error (" Unexpected number of channels" );
179179
180- std::vector<size_t > offsets (decode->channel_count );
181- offsets[0 ] = 0 ;
182- for (int file_i = 1 ; file_i < decode->channel_count ; file_i++)
183- {
184- offsets[file_i] = offsets[file_i - 1 ] +
185- decode->channels [file_i - 1 ].width *
186- decode->channels [file_i - 1 ].bytes_per_element ;
187- }
188180 for (int cs_i = 0 ; cs_i < decode->channel_count ; cs_i++)
189181 {
190- cs_to_file_ch[cs_i].raster_line_offset =
191- offsets[cs_to_file_ch[cs_i].file_index ];
182+ int file_i = cs_to_file_ch[cs_i].file_index ;
183+ if (file_i >= decode->channel_count )
184+ return EXR_ERR_CORRUPT_CHUNK;
185+
186+ size_t computedoffset = 0 ;
187+ for (int i = 0 ; i < file_i; ++i)
188+ computedoffset += decode->channels [i].width *
189+ decode->channels [i].bytes_per_element ;
190+ cs_to_file_ch[cs_i].raster_line_offset = computedoffset;
192191 }
193192
194193 ojph::mem_infile infile;
You can’t perform that action at this time.
0 commit comments