提交 ec09b1c8 authored 作者: Caglar's avatar Caglar

fixed the division by zero.

上级 4937b42b
......@@ -363,7 +363,7 @@ static int CudaNdarray_alloc_contiguous(CudaNdarray *self, const int nd,
CudaNdarray_set_stride(self, i, (dim[i] == 1) ? 0 : size);
CudaNdarray_set_dim(self, i, dim[i]);
//Detect overflow on unsigned integer
if (size > (SIZE_MAX / dim[i])) {
if (dim[i] != 0 && size > (SIZE_MAX / dim[i])) {
PyErr_Format(PyExc_AssertionError,
"Can't store in size_t the bytes resquested",
size);
......@@ -380,7 +380,7 @@ static int CudaNdarray_alloc_contiguous(CudaNdarray *self, const int nd,
CudaNdarray_set_dim(self, i, dim[i]);
//Detect overflow on unsigned integer
if (size > (SIZE_MAX / dim[i])) {
if (dim[i] != 0 && size > (SIZE_MAX / dim[i])) {
PyErr_Format(PyExc_AssertionError,
"Can't store in size_t the bytes resquested",
size);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论