file_systems/QueryParser: Don't try to read the key size of invalid indexes.
Fixes a rare corner case.
This commit is contained in:
@@ -805,6 +805,7 @@ Equation<QueryPolicy>::PrepareQuery(Context* /*context*/, Index& index,
|
|||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
type_code type;
|
type_code type;
|
||||||
|
int32 keySize;
|
||||||
|
|
||||||
// Special case for OP_UNEQUAL - it will always operate through the whole
|
// Special case for OP_UNEQUAL - it will always operate through the whole
|
||||||
// index but we need the call to the original index to get the correct type
|
// index but we need the call to the original index to get the correct type
|
||||||
@@ -812,7 +813,13 @@ Equation<QueryPolicy>::PrepareQuery(Context* /*context*/, Index& index,
|
|||||||
// Try to get an index that holds all files (name)
|
// Try to get an index that holds all files (name)
|
||||||
// Also sets the default type for all attributes without index
|
// Also sets the default type for all attributes without index
|
||||||
// to string.
|
// to string.
|
||||||
type = status < B_OK ? B_STRING_TYPE : QueryPolicy::IndexGetType(index);
|
if (status == B_OK) {
|
||||||
|
type = QueryPolicy::IndexGetType(index);
|
||||||
|
keySize = QueryPolicy::IndexGetKeySize(index);
|
||||||
|
} else {
|
||||||
|
type = B_STRING_TYPE;
|
||||||
|
keySize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (QueryPolicy::IndexSetTo(index, "name") != B_OK)
|
if (QueryPolicy::IndexSetTo(index, "name") != B_OK)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
@@ -821,9 +828,9 @@ Equation<QueryPolicy>::PrepareQuery(Context* /*context*/, Index& index,
|
|||||||
} else {
|
} else {
|
||||||
fHasIndex = true;
|
fHasIndex = true;
|
||||||
type = QueryPolicy::IndexGetType(index);
|
type = QueryPolicy::IndexGetType(index);
|
||||||
|
keySize = QueryPolicy::IndexGetKeySize(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 keySize = QueryPolicy::IndexGetKeySize(index);
|
|
||||||
if (ConvertValue(type, keySize) < B_OK)
|
if (ConvertValue(type, keySize) < B_OK)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user