Kaydet (Commit) 40b0b9ab authored tarafından Mark Hung's avatar Mark Hung Kaydeden (comit) Tomaž Vajngerl

Ensure that OpenCL device id returned from getDeviceSelection() is valid.

Change-Id: I756bb57d471db3d3ca1d9c3733d359c7c16b4e66
Reviewed-on: https://gerrit.libreoffice.org/24959Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMark Page <aptitude@btconnect.com>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 8b994023
...@@ -636,10 +636,15 @@ ds_device getDeviceSelection( ...@@ -636,10 +636,15 @@ ds_device getDeviceSelection(
} }
/* Final device selection */ /* Final device selection */
selectedDevice = aProfile->devices[bestDeviceIdx]; if (bestDeviceIdx >=0 && static_cast< std::vector<ds_device>::size_type> ( bestDeviceIdx ) < aProfile->devices.size() )
bIsDeviceSelected = true; {
selectedDevice = aProfile->devices[bestDeviceIdx];
bIsDeviceSelected = true;
writeDevicesLog(aProfile, sProfilePath, bestDeviceIdx); writeDevicesLog(aProfile, sProfilePath, bestDeviceIdx);
} else {
selectedDevice.eType = DeviceType::NativeCPU;
}
} }
return selectedDevice; return selectedDevice;
} }
......
...@@ -703,6 +703,8 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv ...@@ -703,6 +703,8 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
OUString path; OUString path;
osl::FileBase::getSystemPathFromFileURL(url,path); osl::FileBase::getSystemPathFromFileURL(url,path);
ds_device aSelectedDevice = getDeviceSelection(path, bForceEvaluation); ds_device aSelectedDevice = getDeviceSelection(path, bForceEvaluation);
if ( aSelectedDevice.eType != DeviceType::OpenCLDevice)
return false;
pDeviceId = aSelectedDevice.aDeviceID; pDeviceId = aSelectedDevice.aDeviceID;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment