QueryParser: Equation::Match(): Fix generic attribute case
Init size to the buffer size before passing it to QueryPolicy::NodeGetAttribute(). Since size was 0 by default, we would only read 0 length data.
This commit is contained in:
@@ -708,6 +708,7 @@ Equation<QueryPolicy>::Match(Entry* entry, Node* node,
|
|||||||
// get a pointer to the attribute in question
|
// get a pointer to the attribute in question
|
||||||
union value<QueryPolicy> value;
|
union value<QueryPolicy> value;
|
||||||
uint8* buffer = (uint8*)&value;
|
uint8* buffer = (uint8*)&value;
|
||||||
|
const size_t bufferSize = sizeof(value);
|
||||||
|
|
||||||
// first, check if we are matching for a live query and use that value
|
// first, check if we are matching for a live query and use that value
|
||||||
if (attributeName != NULL && !strcmp(fAttribute, attributeName)) {
|
if (attributeName != NULL && !strcmp(fAttribute, attributeName)) {
|
||||||
@@ -737,6 +738,7 @@ Equation<QueryPolicy>::Match(Entry* entry, Node* node,
|
|||||||
type = B_INT32_TYPE;
|
type = B_INT32_TYPE;
|
||||||
} else {
|
} else {
|
||||||
// then for attributes
|
// then for attributes
|
||||||
|
size = bufferSize;
|
||||||
if (QueryPolicy::NodeGetAttribute(node, fAttribute, buffer, &size,
|
if (QueryPolicy::NodeGetAttribute(node, fAttribute, buffer, &size,
|
||||||
&type) != B_OK) {
|
&type) != B_OK) {
|
||||||
return MatchEmptyString();
|
return MatchEmptyString();
|
||||||
|
|||||||
Reference in New Issue
Block a user