check classname before accessing object_schema iterator for queries

This commit is contained in:
Ari Lazier 2015-09-09 17:27:42 -07:00
parent 6f2b137b1d
commit 18811f294f
1 changed files with 3 additions and 1 deletions

View File

@ -90,7 +90,6 @@ JSObjectRef RJSResultsCreate(JSContextRef ctx, SharedRealm realm, std::string cl
auto object_schema = realm->config().schema->find(className);
if (object_schema == realm->config().schema->end()) {
throw std::runtime_error("Object type '" + className + "' not present in Realm.");
return NULL;
}
return RJSWrapObject<Results *>(ctx, RJSResultsClass(), new Results(realm, *object_schema, table->where()));
}
@ -103,6 +102,9 @@ JSObjectRef RJSResultsCreate(JSContextRef ctx, SharedRealm realm, std::string cl
Query query = table->where();
Schema &schema = *realm->config().schema;
auto object_schema = realm->config().schema->find(className);
if (object_schema == realm->config().schema->end()) {
throw std::runtime_error("Object type '" + className + "' not present in Realm.");
}
@try {
RLMUpdateQueryWithPredicate(&query, [NSPredicate predicateWithFormat:@(queryString.c_str())], schema, *object_schema);
}