Cycles: Apparently board name could be an empty string
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 10 Apr 2017 13:31:21 +0000 (15:31 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 10 Apr 2017 13:31:21 +0000 (15:31 +0200)
intern/cycles/device/opencl/opencl_util.cpp

index 6dca642f3f37df854c7bb030a7337271046e20f3..fe1c65a2224d3c2217a8e16f6d0af6f29fd96a20 100644 (file)
@@ -1058,13 +1058,16 @@ cl_device_type OpenCLInfo::get_device_type(cl_device_id device_id)
 string OpenCLInfo::get_readable_device_name(cl_device_id device_id)
 {
        char board_name[1024];
+       size_t length = 0;
        if(clGetDeviceInfo(device_id,
                           CL_DEVICE_BOARD_NAME_AMD,
                           sizeof(board_name),
                           &board_name,
-                          NULL) == CL_SUCCESS)
+                                          &length) == CL_SUCCESS)
        {
-               return board_name;
+               if(length != 0 && board_name[0] != '\0') {
+                       return board_name;
+               }
        }
        /* Fallback to standard device name API. */
        return get_device_name(device_id);