Skip to content

Commit

Permalink
Fix loop logic error in maskedCopy.
Browse files Browse the repository at this point in the history
Prevents segfault when the src tensor is empty.
  • Loading branch information
dominikgrewe committed Jun 26, 2015
1 parent 38bbb02 commit 986ef6f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/TH/generic/THTensorMath.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ void THTensor_(maskedCopy)(THTensor *tensor, THByteTensor *mask, THTensor* src )
}
else if (*mask_data == 1)
{
if (cntr == nelem)
THError("Number of elements of src < number of ones in mask");
*tensor_data = *src_data;
src_data++;
cntr++;
if (cntr > nelem)
THError("Number of elements of src < number of ones in mask");
});
THTensor_(free)(srct);
}
Expand Down

0 comments on commit 986ef6f

Please sign in to comment.