Bug 1086596 - Fix potential crash if get camera boolean parameter is misused. r=mikeh

This commit is contained in:
Andrew Osmond 2014-10-21 10:29:00 -04:00
parent cee822c738
commit 341f434a1e
2 changed files with 8 additions and 2 deletions

View File

@ -352,7 +352,7 @@ GonkCameraParameters::SetTranslated(uint32_t aKey, const ICameraControl::Size& a
if (aSize.width > INT_MAX || aSize.height > INT_MAX) {
// AOSP can only handle signed ints.
DOM_CAMERA_LOGE("Camera parameter aKey=%d out of bounds (width=%u, height=%u)\n",
aSize.width, aSize.height);
aKey, aSize.width, aSize.height);
return NS_ERROR_INVALID_ARG;
}

View File

@ -121,7 +121,13 @@ protected:
void get(const char* aKey, double& aRet) { aRet = getFloat(aKey); }
void get(const char* aKey, const char*& aRet) { aRet = get(aKey); }
void get(const char* aKey, int& aRet) { aRet = getInt(aKey); }
void get(const char* aKey, bool& aRet) { aRet = strcmp(get(aKey), FALSE); }
void
get(const char* aKey, bool& aRet)
{
const char* value = get(aKey);
aRet = value ? strcmp(value, TRUE) == 0 : false;
}
void remove(const char* aKey) { android::CameraParameters::remove(aKey); }