Skip to content

Commit

Permalink
Bugfix in GpuReduction_new().
Browse files Browse the repository at this point in the history
  • Loading branch information
obilaniu committed Aug 27, 2017
1 parent c679474 commit ecde75c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/gpuarray_reduction.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ GPUARRAY_PUBLIC void GpuReductionAttr_free (GpuReductionAttr*
}
GPUARRAY_PUBLIC int GpuReduction_new (GpuReduction** gr,
const GpuReductionAttr* grAttr){
int ret;
GpuReduction* grOut = NULL;

if (!gr){
Expand All @@ -665,8 +666,16 @@ GPUARRAY_PUBLIC int GpuReduction_new (GpuReduction**
grOut->ndd = (int)grAttr->maxDstDims;
grOut->ndr = (int)(grAttr->maxSrcDims - grAttr->maxDstDims);

return reduxGenInit(grOut);
ret = reduxGenInit(grOut);
if(ret == GA_NO_ERROR){
*gr = grOut;
}else{
GpuReduction_free(grOut);
*gr = NULL;
}
return ret;
}else{
*gr = NULL;
return GA_MEMORY_ERROR;
}
}
Expand Down

0 comments on commit ecde75c

Please sign in to comment.