mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-24 23:16:10 +00:00
Fixed reflection resizing code not checking strings in vectors.
Change-Id: I4081160a8281939ab282d7914ae396276c767882 Tested: on Linux.
This commit is contained in:
@@ -354,18 +354,22 @@ class ResizeContext {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case reflection::Vector: {
|
case reflection::Vector: {
|
||||||
if (fielddef.type()->element() != reflection::Obj) break;
|
auto elem_type = fielddef.type()->element();
|
||||||
|
if (elem_type != reflection::Obj && elem_type != reflection::String)
|
||||||
|
break;
|
||||||
auto vec = reinterpret_cast<Vector<uoffset_t> *>(ref);
|
auto vec = reinterpret_cast<Vector<uoffset_t> *>(ref);
|
||||||
auto elemobjectdef =
|
auto elemobjectdef = elem_type == reflection::Obj
|
||||||
schema_.objects()->Get(fielddef.type()->index());
|
? schema_.objects()->Get(fielddef.type()->index())
|
||||||
if (elemobjectdef->is_struct()) break;
|
: nullptr;
|
||||||
|
if (elemobjectdef && elemobjectdef->is_struct()) break;
|
||||||
for (uoffset_t i = 0; i < vec->size(); i++) {
|
for (uoffset_t i = 0; i < vec->size(); i++) {
|
||||||
auto loc = vec->Data() + i * sizeof(uoffset_t);
|
auto loc = vec->Data() + i * sizeof(uoffset_t);
|
||||||
if (DagCheck(loc))
|
if (DagCheck(loc))
|
||||||
continue; // This offset already visited.
|
continue; // This offset already visited.
|
||||||
auto dest = loc + vec->Get(i);
|
auto dest = loc + vec->Get(i);
|
||||||
Straddle<uoffset_t, 1>(loc, dest ,loc);
|
Straddle<uoffset_t, 1>(loc, dest ,loc);
|
||||||
ResizeTable(*elemobjectdef, reinterpret_cast<Table *>(dest));
|
if (elemobjectdef)
|
||||||
|
ResizeTable(*elemobjectdef, reinterpret_cast<Table *>(dest));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user