diff options
author | Tomas Farago <sensej007@email.cz> | 2021-12-17 17:42:40 +0100 |
---|---|---|
committer | Tomas Farago <sensej007@email.cz> | 2021-12-17 17:42:40 +0100 |
commit | 065756bd0d540b654682bdb042bb434387e6f3ed (patch) | |
tree | e0d8419686dd6d2aabe1113b79d8efd1a7434bb4 | |
parent | 6cffd94d4d266b023015d21ec8963344cf5d3fb3 (diff) | |
download | ufo-filters-065756bd0d540b654682bdb042bb434387e6f3ed.tar.gz ufo-filters-065756bd0d540b654682bdb042bb434387e6f3ed.tar.bz2 ufo-filters-065756bd0d540b654682bdb042bb434387e6f3ed.tar.xz ufo-filters-065756bd0d540b654682bdb042bb434387e6f3ed.zip |
read: check sizes on get_meta
-rw-r--r-- | src/ufo-read-task.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/ufo-read-task.c b/src/ufo-read-task.c index f4818e0..5aeb731 100644 --- a/src/ufo-read-task.c +++ b/src/ufo-read-task.c @@ -278,6 +278,22 @@ ufo_read_task_get_requisition (UfoTask *task, if (!ufo_reader_get_meta (priv->reader, requisition, &num_images, &priv->depth, error)) return; + if (priv->roi_y >= requisition->dims[1]) { + g_warning ("read: vertical ROI start %i >= height %zu", + priv->roi_y, requisition->dims[1]); + priv->roi_y = 0; + } + + if (!priv->roi_height) { + priv->roi_height = requisition->dims[1] - priv->roi_y; + } + else { + if (priv->roi_y + priv->roi_height > requisition->dims[1]) { + g_warning ("read: vertical ROI height %i >= height %zu", + priv->roi_height, requisition->dims[1]); + priv->roi_height = requisition->dims[1] - priv->roi_y; + } + } if (priv->image_start >= num_images) { priv->image_start -= num_images; } else { @@ -295,23 +311,6 @@ ufo_read_task_get_requisition (UfoTask *task, */ priv->depth = UFO_BUFFER_DEPTH_32F; - if (priv->roi_y >= requisition->dims[1]) { - g_warning ("read: vertical ROI start %i >= height %zu", - priv->roi_y, requisition->dims[1]); - priv->roi_y = 0; - } - - if (!priv->roi_height) { - priv->roi_height = requisition->dims[1] - priv->roi_y; - } - else { - if (priv->roi_y + priv->roi_height > requisition->dims[1]) { - g_warning ("read: vertical ROI height %i >= height %zu", - priv->roi_height, requisition->dims[1]); - priv->roi_height = requisition->dims[1] - priv->roi_y; - } - } - /* update height for reduced vertical ROI and allow things like roi_height=1 * and roi_step=20 */ requisition->dims[1] = (priv->roi_height - 1) / priv->roi_step + 1; |