File tree 2 files changed +24
-4
lines changed
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(
280
280
281
281
std::unique_ptr<ur_event_handle_t_> EventPtr{nullptr };
282
282
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 ();
285
294
286
295
return UR_RESULT_SUCCESS;
287
296
}
Original file line number Diff line number Diff line change @@ -327,8 +327,19 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventCreateWithNativeHandle(
327
327
ur_event_handle_t *phEvent) {
328
328
std::ignore = pProperties;
329
329
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 ();
332
343
333
344
return UR_RESULT_SUCCESS;
334
345
}
You can’t perform that action at this time.
0 commit comments