Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification needed to prevent an out-of-bounds memory access condition #1263

Merged
merged 1 commit into from
Oct 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions gpu/kinfu_large_scale/src/cuda/extract.cu
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,14 @@ namespace pcl
storage_Z[storage_index + offset + l] = points[l].z;
}

PointType *pos = output_xyz.data + old_global_count + lane;
for (int idx = lane; idx < total_warp; idx += Warp::STRIDE, pos += Warp::STRIDE)
int offset_storage = old_global_count + lane;
for (int idx = lane; idx < total_warp; idx += Warp::STRIDE, offset_storage += Warp::STRIDE)
{
if (offset_storage >= output_xyz.size) break;
float x = storage_X[storage_index + idx];
float y = storage_Y[storage_index + idx];
float z = storage_Z[storage_index + idx];
store_point_type (x, y, z, pos);
store_point_type (x, y, z, output_xyz.data, offset_storage);
}

bool full = (old_global_count + total_warp) >= output_xyz.size;
Expand Down Expand Up @@ -352,6 +353,7 @@ namespace pcl
int offset_storage = old_global_count + lane;
for (int idx = lane; idx < total_warp; idx += Warp::STRIDE, offset_storage += Warp::STRIDE)
{
if (offset_storage >= output_xyz.size) break;
float x = storage_X[storage_index + idx];
float y = storage_Y[storage_index + idx];
float z = storage_Z[storage_index + idx];
Expand Down Expand Up @@ -386,9 +388,9 @@ namespace pcl
} /* operator() */

__device__ __forceinline__ void
store_point_type (float x, float y, float z, float4* ptr) const
store_point_type (float x, float y, float z, float4* ptr, int offset) const
{
*ptr = make_float4 (x, y, z, 0);
*(ptr + offset) = make_float4 (x, y, z, 0);
}

//INLINE FUNCTION THAT STORES XYZ AND INTENSITY VALUES IN 2 SEPARATE DeviceArrays.
Expand All @@ -403,9 +405,9 @@ namespace pcl
}

__device__ __forceinline__ void
store_point_type (float x, float y, float z, float3* ptr) const
store_point_type (float x, float y, float z, float3* ptr, int offset) const
{
*ptr = make_float3 (x, y, z);
*(ptr + offset) = make_float3 (x, y, z);
}
};

Expand Down