File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -455,32 +455,40 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageAllocateExp(
455455
456456 // Allocate a cuArray
457457 if (pImageDesc->numMipLevel == 1 ) {
458- CUarray ImageArray;
458+ CUarray ImageArray{} ;
459459
460460 try {
461461 UR_CHECK_ERROR (cuArray3DCreate (&ImageArray, &array_desc));
462462 *phImageMem = (ur_exp_image_mem_native_handle_t )ImageArray;
463463 } catch (ur_result_t Err) {
464- cuArrayDestroy (ImageArray);
464+ if (ImageArray) {
465+ UR_CHECK_ERROR (cuArrayDestroy (ImageArray));
466+ }
465467 return Err;
466468 } catch (...) {
467- cuArrayDestroy (ImageArray);
469+ if (ImageArray) {
470+ UR_CHECK_ERROR (cuArrayDestroy (ImageArray));
471+ }
468472 return UR_RESULT_ERROR_UNKNOWN;
469473 }
470474 } else // Allocate a cuMipmappedArray
471475 {
472- CUmipmappedArray mip_array;
476+ CUmipmappedArray mip_array{} ;
473477 array_desc.Flags = CUDA_ARRAY3D_SURFACE_LDST;
474478
475479 try {
476480 UR_CHECK_ERROR (cuMipmappedArrayCreate (&mip_array, &array_desc,
477481 pImageDesc->numMipLevel ));
478482 *phImageMem = (ur_exp_image_mem_native_handle_t )mip_array;
479483 } catch (ur_result_t Err) {
480- cuMipmappedArrayDestroy (mip_array);
484+ if (mip_array) {
485+ UR_CHECK_ERROR (cuMipmappedArrayDestroy (mip_array));
486+ }
481487 return Err;
482488 } catch (...) {
483- cuMipmappedArrayDestroy (mip_array);
489+ if (mip_array) {
490+ UR_CHECK_ERROR (cuMipmappedArrayDestroy (mip_array));
491+ }
484492 return UR_RESULT_ERROR_UNKNOWN;
485493 }
486494 }
Original file line number Diff line number Diff line change @@ -439,7 +439,7 @@ ur_result_t allocateMemObjOnDeviceIfNeeded(ur_mem_handle_t Mem,
439439 UR_CHECK_ERROR (cuMemAlloc (&DevPtr, Buffer.Size ));
440440 }
441441 } else {
442- CUarray ImageArray;
442+ CUarray ImageArray{} ;
443443 CUsurfObject Surface;
444444 try {
445445 auto &Image = std::get<SurfaceMem>(Mem->Mem );
Original file line number Diff line number Diff line change @@ -498,7 +498,7 @@ ur_result_t allocateMemObjOnDeviceIfNeeded(ur_mem_handle_t Mem,
498498 UR_CHECK_ERROR (hipMalloc (&DevPtr, Buffer.Size ));
499499 }
500500 } else {
501- hipArray *ImageArray;
501+ hipArray *ImageArray{} ;
502502 hipSurfaceObject_t Surface;
503503 try {
504504 auto &Image = std::get<SurfaceMem>(Mem->Mem );
You can’t perform that action at this time.
0 commit comments