Add additional error checking for CefV8Value methods (issue #427).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@381 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-11-16 22:12:54 +00:00
parent 0f10560d27
commit 268675fdbe
3 changed files with 114 additions and 31 deletions

View File

@@ -276,6 +276,10 @@ bool CefV8ValueCToCpp::HasValue(int index)
if(CEF_MEMBER_MISSING(struct_, has_value_byindex))
return false;
DCHECK(index >= 0);
if (index < 0)
return false;
return struct_->has_value_byindex(struct_, index)?true:false;
}
@@ -284,6 +288,10 @@ bool CefV8ValueCToCpp::DeleteValue(const CefString& key)
if(CEF_MEMBER_MISSING(struct_, delete_value_bykey))
return false;
DCHECK(!key.empty());
if (key.empty())
return false;
return struct_->delete_value_bykey(struct_, key.GetStruct())?true:false;
}
@@ -292,6 +300,10 @@ bool CefV8ValueCToCpp::DeleteValue(int index)
if(CEF_MEMBER_MISSING(struct_, delete_value_byindex))
return false;
DCHECK(index >= 0);
if (index < 0)
return false;
return struct_->delete_value_byindex(struct_, index)?true:false;
}
@@ -300,6 +312,10 @@ CefRefPtr<CefV8Value> CefV8ValueCToCpp::GetValue(const CefString& key)
if(CEF_MEMBER_MISSING(struct_, get_value_bykey))
return NULL;
DCHECK(!key.empty());
if (key.empty())
return NULL;
cef_v8value_t* valueStruct = struct_->get_value_bykey(struct_,
key.GetStruct());
if(valueStruct)
@@ -312,6 +328,10 @@ CefRefPtr<CefV8Value> CefV8ValueCToCpp::GetValue(int index)
if(CEF_MEMBER_MISSING(struct_, get_value_byindex))
return NULL;
DCHECK(index >= 0);
if (index < 0)
return NULL;
cef_v8value_t* valueStruct = struct_->get_value_byindex(struct_, index);
if(valueStruct)
return CefV8ValueCToCpp::Wrap(valueStruct);
@@ -324,6 +344,11 @@ bool CefV8ValueCToCpp::SetValue(const CefString& key,
if(CEF_MEMBER_MISSING(struct_, set_value_bykey))
return false;
DCHECK(!key.empty());
DCHECK(value.get());
if (key.empty() || !value.get())
return false;
return struct_->set_value_bykey(struct_, key.GetStruct(),
CefV8ValueCToCpp::Unwrap(value), attribute)?true:false;
}
@@ -333,6 +358,11 @@ bool CefV8ValueCToCpp::SetValue(int index, CefRefPtr<CefV8Value> value)
if(CEF_MEMBER_MISSING(struct_, set_value_byindex))
return false;
DCHECK(index >= 0);
DCHECK(value.get());
if (index < 0 || !value.get())
return false;
return struct_->set_value_byindex(struct_, index,
CefV8ValueCToCpp::Unwrap(value))?true:false;
}
@@ -343,6 +373,10 @@ bool CefV8ValueCToCpp::SetValue(const CefString& key, AccessControl settings,
if(CEF_MEMBER_MISSING(struct_, set_value_byaccessor))
return false;
DCHECK(!key.empty());
if (key.empty())
return false;
return struct_->set_value_byaccessor(struct_, key.GetStruct(),
settings, attribute)?true:false;
}