Skip to content

Commit ecde75c

Browse files
committed
Bugfix in GpuReduction_new().
1 parent c679474 commit ecde75c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/gpuarray_reduction.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ GPUARRAY_PUBLIC void GpuReductionAttr_free (GpuReductionAttr*
648648
}
649649
GPUARRAY_PUBLIC int GpuReduction_new (GpuReduction** gr,
650650
const GpuReductionAttr* grAttr){
651+
int ret;
651652
GpuReduction* grOut = NULL;
652653

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

668-
return reduxGenInit(grOut);
669+
ret = reduxGenInit(grOut);
670+
if(ret == GA_NO_ERROR){
671+
*gr = grOut;
672+
}else{
673+
GpuReduction_free(grOut);
674+
*gr = NULL;
675+
}
676+
return ret;
669677
}else{
678+
*gr = NULL;
670679
return GA_MEMORY_ERROR;
671680
}
672681
}

0 commit comments

Comments
 (0)