Skip to content

Commit

Permalink
Fixed out-of-bounds memory access in CUDA/OpenCL SIFT
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Andreas Entschev committed Oct 14, 2015
1 parent f8462bc commit 7fc3856
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/backend/cuda/kernel/sift_nonfree.hpp
Expand Up @@ -333,8 +333,10 @@ __global__ void sub(
{
unsigned i = blockIdx.x * blockDim.x + threadIdx.x;

for (unsigned l = 0; l < n_layers; l++)
out.ptr[l*nel + i] = in.ptr[(l+1)*nel + i] - in.ptr[l*nel + i];
if (i < nel) {
for (unsigned l = 0; l < n_layers; l++)
out.ptr[l*nel + i] = in.ptr[(l+1)*nel + i] - in.ptr[l*nel + i];
}
}

#define SCPTR(Y, X) (s_center[(Y) * s_i + (X)])
Expand Down
6 changes: 4 additions & 2 deletions src/backend/opencl/kernel/sift_nonfree.cl
Expand Up @@ -255,8 +255,10 @@ __kernel void sub(
{
unsigned i = get_global_id(0);

for (unsigned l = 0; l < n_layers; l++)
out[l*nel + i] = in[l*nel + i] - in[(l+1)*nel + i];
if (i < nel) {
for (unsigned l = 0; l < n_layers; l++)
out[l*nel + i] = in[l*nel + i] - in[(l+1)*nel + i];
}
}

#define LCPTR(Y, X) (l_center[(Y) * l_i + (X)])
Expand Down

0 comments on commit 7fc3856

Please sign in to comment.