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

Coverity analysis defect 76371: Dereference null return value

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

      Return value of function which returns null is dereferenced without checking

      Defect 76371 (STATIC_C)
      Checker NULL_RETURNS (subcategory none)
      File: /src/mongoc/mongoc-collection.c
      Function mongoc_collection_create_index
      /src/mongoc/mongoc-collection.c, line: 821
      Assigning: "alloc_name" = null return value from "mongoc_collection_keys_to_index_string".

                alloc_name = mongoc_collection_keys_to_index_string (keys);
      

      /src/mongoc/mongoc-collection.c, line: 822
      Assigning: "name" = "alloc_name". Both pointers are now null.

                name = alloc_name;
      

      /src/mongoc/mongoc-collection.c, line: 832
      Dereferencing a pointer that might be null "name" when calling "strlen".

             BSON_APPEND_UTF8 (&doc, "name", name);
      

            Assignee:
            bjori Hannes Magnusson
            Reporter:
            xgen-internal-coverity Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: