Uploaded image for project: 'Couchbase Lite'
  1. Couchbase Lite
  2. CBL-2572

Database getIndexNames() returns invalid data

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.1.0
    • 3.0
    • C
    • Security Level: Public
    • None
    • Pasin 61
    • 3

    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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            pasin Pasin Suriyentrakorn
            jimb Jim Borden
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty