File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -280,8 +280,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventCreateWithNativeHandle(
280280
281281 std::unique_ptr<ur_event_handle_t_> EventPtr{nullptr };
282282
283- *phEvent = ur_event_handle_t_::makeWithNative (
284- hContext, reinterpret_cast <CUevent>(hNativeEvent));
283+ try {
284+ EventPtr =
285+ std::unique_ptr<ur_event_handle_t_>(ur_event_handle_t_::makeWithNative (
286+ hContext, reinterpret_cast <CUevent>(hNativeEvent)));
287+ } catch (const std::bad_alloc &) {
288+ return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
289+ } catch (...) {
290+ return UR_RESULT_ERROR_UNKNOWN;
291+ }
292+
293+ *phEvent = EventPtr.release ();
285294
286295 return UR_RESULT_SUCCESS;
287296}
Original file line number Diff line number Diff line change @@ -327,8 +327,19 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventCreateWithNativeHandle(
327327 ur_event_handle_t *phEvent) {
328328 std::ignore = pProperties;
329329
330- *phEvent = ur_event_handle_t_::makeWithNative (
331- hContext, reinterpret_cast <hipEvent_t>(hNativeEvent));
330+ std::unique_ptr<ur_event_handle_t_> EventPtr{nullptr };
331+
332+ try {
333+ EventPtr =
334+ std::unique_ptr<ur_event_handle_t_>(ur_event_handle_t_::makeWithNative (
335+ hContext, reinterpret_cast <hipEvent_t>(hNativeEvent)));
336+ } catch (const std::bad_alloc &) {
337+ return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
338+ } catch (...) {
339+ return UR_RESULT_ERROR_UNKNOWN;
340+ }
341+
342+ *phEvent = EventPtr.release ();
332343
333344 return UR_RESULT_SUCCESS;
334345}
You can’t perform that action at this time.
0 commit comments