• Giuseppe Bilotta's avatar
    OpenCL: correctly handle platforms without devices · 0d4204e8
    Giuseppe Bilotta yazdı
    When an OpenCL platform has no devices (of the requested type), calls to
    clGetDeviceIDs() are required to return with the error value
    CL_DEVICE_NOT_FOUND.
    
    Some platforms (e.g. Clover as of Mesa 10.4.2) do not touch their output
    parameters in such cases, which means that in some conditions the `num`
    variable where the number of devices of the platform should be stored
    may be used uninitialized. This can lead to segmentations faults in the
    subsequent calls to clGetDeviceInfo().
    
    Simply reinitializing num to 0 is sufficient to prevent the segfault in
    the case of Mesa, but proper error handling is included for
    completeness.
    
    Change-Id: Ia25192f6aa953838a545a9e7c9fca050d2703b60
    Reviewed-on: https://gerrit.libreoffice.org/14700Tested-by: 's avatarJenkins <ci@libreoffice.org>
    Reviewed-by: 's avatarTor Lillqvist <tml@collabora.com>
    0d4204e8
opencl_device_selection.h 22.1 KB