Add paranoid error check when listing cameras

This commit is contained in:
Henrik Rydgård 2023-12-20 18:21:32 +01:00
parent 72e46acf14
commit 8810d95ab4

View File

@ -1482,8 +1482,12 @@ std::vector<std::string> System_GetCameraDeviceList() {
for (int i = 0; i < arrayListObjectLen; i++) {
jstring dev = static_cast<jstring>(getEnv()->CallObjectMethod(deviceListObject, arrayListGet, i));
const char* cdev = getEnv()->GetStringUTFChars(dev, nullptr);
deviceListVector.push_back(cdev);
const char *cdev = getEnv()->GetStringUTFChars(dev, nullptr);
if (!cdev) {
getEnv()->DeleteLocalRef(dev);
continue;
}
deviceListVector.push_back(std::string(cdev));
getEnv()->ReleaseStringUTFChars(dev, cdev);
getEnv()->DeleteLocalRef(dev);
}