From a73a17763d6b6a40ae4435eddca246e952e12c70 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/clr commit: 21de66889c2d4c7611655375abaf07697d5bb242] --- projects/clr/hipamd/src/hip_event.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/clr/hipamd/src/hip_event.cpp b/projects/clr/hipamd/src/hip_event.cpp index ab1c43a00b..71da9fdc30 100644 --- a/projects/clr/hipamd/src/hip_event.cpp +++ b/projects/clr/hipamd/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)