[Beignet] [PATCH] Runtime: fixed the region check for three rect region related APIs.
Yang, Rong R
rong.r.yang at intel.com
Mon Dec 9 18:33:38 PST 2013
LGTM, thanks.
-----Original Message-----
From: beignet-bounces at lists.freedesktop.org [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Zhigang Gong
Sent: Wednesday, December 04, 2013 6:23 PM
To: beignet at lists.freedesktop.org
Cc: Gong, Zhigang
Subject: [Beignet] [PATCH] Runtime: fixed the region check for three rect region related APIs.
Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
src/cl_api.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/cl_api.c b/src/cl_api.c index 1c1c941..e8e22e5 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -1423,7 +1423,9 @@ clEnqueueReadBufferRect(cl_command_queue command_queue,
goto error;
}
- if ((buffer_origin[2]+region[2])*buffer_slice_pitch + (buffer_origin[1]+region[1])*buffer_row_pitch + buffer_origin[0] + region[0] > buffer->size) {
+ if ((buffer_origin[2] + region[2] - 1) * buffer_slice_pitch
+ + (buffer_origin[1] + region[1] - 1) * buffer_row_pitch
+ + buffer_origin[0] + region[0] > buffer->size) {
err = CL_INVALID_VALUE;
goto error;
}
@@ -1556,7 +1558,9 @@ clEnqueueWriteBufferRect(cl_command_queue command_queue,
goto error;
}
- if ((buffer_origin[2]+region[2])*buffer_slice_pitch + (buffer_origin[1]+region[1])*buffer_row_pitch + buffer_origin[0] + region[0] > buffer->size) {
+ if ((buffer_origin[2] + region[2] - 1) * buffer_slice_pitch
+ + (buffer_origin[1] + region[1] - 1) * buffer_row_pitch
+ + buffer_origin[0] + region[0] > buffer->size) {
err = CL_INVALID_VALUE;
goto error;
}
@@ -1724,8 +1728,12 @@ clEnqueueCopyBufferRect(cl_command_queue command_queue,
goto error;
}
- if ((src_origin[2]+region[2])*src_slice_pitch + (src_origin[1]+region[1])*src_row_pitch + src_origin[0] + region[0] > src_buffer->size ||
- (dst_origin[2]+region[2])*dst_slice_pitch + (dst_origin[1]+region[1])*dst_row_pitch + dst_origin[0] + region[0] > dst_buffer->size) {
+ if ((src_origin[2] + region[2] - 1) * src_slice_pitch
+ + (src_origin[1] + region[1] - 1) * src_row_pitch
+ + src_origin[0] + region[0] > src_buffer->size
+ ||(dst_origin[2] + region[2] - 1) * dst_slice_pitch
+ + (dst_origin[1] + region[1] - 1) * dst_row_pitch
+ + dst_origin[0] + region[0] > dst_buffer->size) {
err = CL_INVALID_VALUE;
goto error;
}
--
1.7.9.5
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list