Bug 1519535 - Check that deviceNumber is valid in GetDeviceName; r=jib

Differential Revision: https://phabricator.services.mozilla.com/D21945

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dan Minor 2019-03-06 15:41:35 +00:00
Родитель 6a11c5c4c0
Коммит 0aa8a8ce34
1 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -67,7 +67,10 @@ int32_t DeviceInfoIos::Init() {
char deviceNameUTF8[256]; char deviceNameUTF8[256];
char deviceId[256]; char deviceId[256];
this->GetDeviceName(i, deviceNameUTF8, 256, deviceId, 256); int error = this->GetDeviceName(i, deviceNameUTF8, 256, deviceId, 256);
if (error) {
return error;
}
std::string deviceIdCopy(deviceId); std::string deviceIdCopy(deviceId);
std::pair<std::string, VideoCaptureCapabilities> mapPair = std::pair<std::string, VideoCaptureCapabilities> mapPair =
std::pair<std::string, VideoCaptureCapabilities>(deviceIdCopy, capabilityVector); std::pair<std::string, VideoCaptureCapabilities>(deviceIdCopy, capabilityVector);
@ -89,6 +92,11 @@ int32_t DeviceInfoIos::GetDeviceName(uint32_t deviceNumber,
char* productUniqueIdUTF8, char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length, uint32_t productUniqueIdUTF8Length,
pid_t* pid) { pid_t* pid) {
if (deviceNumber >= NumberOfDevices()) {
return -1;
}
NSString* deviceName = [DeviceInfoIosObjC deviceNameForIndex:deviceNumber]; NSString* deviceName = [DeviceInfoIosObjC deviceNameForIndex:deviceNumber];
NSString* deviceUniqueId = [DeviceInfoIosObjC deviceUniqueIdForIndex:deviceNumber]; NSString* deviceUniqueId = [DeviceInfoIosObjC deviceUniqueIdForIndex:deviceNumber];