File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 2222#include < ImfStdIO.h>
2323#include < ImfTileDescription.h>
2424#include < ImfXdr.h>
25+ #include < cassert>
2526
2627OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
2728
@@ -275,6 +276,20 @@ copyIntoFrameBuffer (
275276 //
276277 endPtr += xStride;
277278
279+ if (xStride == 0 )
280+ {
281+ throw IEX_NAMESPACE::ArgExc (" Zero stride is invalid." );
282+ }
283+ if ((endPtr - writePtr) / xStride <= 0 )
284+ {
285+ // Nothing to do, the specified range is empty.
286+ return ;
287+ }
288+ if ((endPtr - writePtr) % xStride != 0 )
289+ {
290+ throw IEX_NAMESPACE::ArgExc (" Stride will not exactly span input data." );
291+ }
292+
278293 if (fill)
279294 {
280295 //
@@ -1533,6 +1548,21 @@ copyFromFrameBuffer (
15331548 char * localWritePtr = writePtr;
15341549 const char * localReadPtr = readPtr;
15351550 endPtr += xStride;
1551+
1552+ if (xStride == 0 )
1553+ {
1554+ throw IEX_NAMESPACE::ArgExc (" Zero stride is invalid." );
1555+ }
1556+ if ((endPtr - localReadPtr) / xStride <= 0 )
1557+ {
1558+ // Nothing to do, the specified range is empty.
1559+ return ;
1560+ }
1561+ if ((endPtr - localReadPtr) % xStride != 0 )
1562+ {
1563+ throw IEX_NAMESPACE::ArgExc (" Stride will not exactly span input data." );
1564+ }
1565+
15361566 //
15371567 // Copy a horizontal row of pixels from a frame
15381568 // buffer to an output file's line or tile buffer.
You can’t perform that action at this time.
0 commit comments