Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-381

libbson: bson_as_json returns incorrect length for empty object

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 0.96.4
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      The bson_as_json function has a shortcut for an empty object, which has this code:

         if (bson_empty0 (bson)) {
            if (length) {
               *length = 2;
            }
      
            return bson_strdup ("{ }");
         }
      

      https://github.com/mongodb/libbson/blob/master/src/bson/bson.c#L2672

      As you can see, the returned string is three characters long, but we only return 2 as the output length. It should be 3.

            Assignee:
            christian.hergert@10gen.com Christian Hergert
            Reporter:
            itay Itay Neeman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: