diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2013-11-28 23:59:50 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2013-11-29 00:02:11 +0000 |
commit | 169658bfa38c684219e24a2e30893e1e30ea6621 (patch) | |
tree | 7077976e671d3783989610abdd47e4ae95ea63c6 /sc | |
parent | 891c3f308ada19030ac4cdbed192ae5b0ea846aa (diff) |
GPU Calc: Avoid dereferencing null 'score' field in some cases.
Change-Id: I2e76d19986326b15c088e6dcce1da3be3924d0fc
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/opencl_device.cxx | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/sc/source/core/opencl/opencl_device.cxx b/sc/source/core/opencl/opencl_device.cxx index a3fa004b988e..80062c6a9877 100644 --- a/sc/source/core/opencl/opencl_device.cxx +++ b/sc/source/core/opencl/opencl_device.cxx @@ -391,19 +391,26 @@ ds_status pickBestDevice(ds_profile* profile, int* bestDeviceIdx) for (unsigned int d = 0; d < profile->numDevices; d++) { - ds_device device = profile->devices[d]; - LibreOfficeDeviceScore score = *(LibreOfficeDeviceScore*)device.score; + ds_device device = profile->devices[d]; + LibreOfficeDeviceScore *pScore = (LibreOfficeDeviceScore*)device.score; + + float fScore = -1; + if (pScore) + fScore = pScore->fTime; + else + LOG_PRINTF("Unusual null score"); + if (DS_DEVICE_OPENCL_DEVICE == device.type) { - LOG_PRINTF("[DS] Device[" << d << "] " << device.oclDeviceName << " (OpenCL) score is " << score.fTime); + LOG_PRINTF("[DS] Device[" << d << "] " << device.oclDeviceName << " (OpenCL) score is " << fScore); } else { - LOG_PRINTF("[DS] Device[" << d << "] CPU (Native) score is " << score.fTime); + LOG_PRINTF("[DS] Device[" << d << "] CPU (Native) score is " << fScore); } - if (score.fTime < bestScore) + if (fScore < bestScore) { - bestScore = score.fTime; + bestScore = fScore; *bestDeviceIdx = d; } } |