From f4ca1c96c4ab0e8f1d129d23708b1eae142f2f5e Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Tue, 18 Jul 2017 11:01:02 +0530 Subject: [PATCH] Don't crash for hipEventDestroy(NULL) Change-Id: I3f4de1ad2712dbe8af81e10c5d3bef16d468c582 [ROCm/hip commit: 7ddb6b6b76fa5cb10047f02ad8537478c0eaf5d3] --- projects/hip/src/hip_event.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/hip/src/hip_event.cpp b/projects/hip/src/hip_event.cpp index ab1c43a00b..71da9fdc30 100644 --- a/projects/hip/src/hip_event.cpp +++ b/projects/hip/src/hip_event.cpp @@ -164,13 +164,16 @@ hipError_t hipEventDestroy(hipEvent_t event) { HIP_INIT_API(event); - event->_state = hipEventStatusUnitialized; + if (event) { + event->_state = hipEventStatusUnitialized; - delete event; - event = NULL; + delete event; + event = NULL; - // TODO - examine return additional error codes - return ihipLogStatus(hipSuccess); + return ihipLogStatus(hipSuccess); + } else { + return ihipLogStatus(hipErrorInvalidResourceHandle); + } } hipError_t hipEventSynchronize(hipEvent_t event)