Description
When using the C++ database class, I notice that it returns invalid data. I think that it is returning data after free since I have the following snippet:
auto names = db.getIndexNames();
|
std::cerr << names.type() << std::endl;
|
Which outputs 2 (aka kFLNumber) instead of the correct 5 (kFLArray)
The implementation of getIndexNames() is currently
fleece::Array getIndexNames() {
|
FLArray flNames = CBLDatabase_GetIndexNames(ref());
|
fleece::Array names(flNames);
|
FLArray_Release(flNames);
|
return names; |
}
|
I don't see anywhere that fleece::Array will retain the result, so it looks like it releases the memory before returning it. Removing the release call here will cause the correct output, however the object is leaked of course.