CUDA: fix double-free when double-waiting
Waiting multiple times on the same even results in the command's
finalization being run twice, which in turn results in a double call to
pocl_ndrange_node_cleanup for the same command, and finally a
double-free.
The solution is simply to not finalize the command again if it has
finished already.
@@ -1471,6 +1471,7 @@ pocl_cuda_wait_event_recurse (cl_device_id device, cl_event event)
while (event->wait_list)
pocl_cuda_wait_event_recurse (device, event->wait_list->event);
+ if (event->status > CL_COMPLETE)
pocl_cuda_finalize_command (device, event);
}
