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

libbson: bson_as_json returns incorrect length for empty object

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.96.4
    • Component/s: None
    • Labels:

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: