Uploaded image for project: 'Couchbase C client library libcouchbase'
  1. Couchbase C client library libcouchbase
  2. CCBC-65

Memory leak in libcouchbase_create / libcouchbase_destroy (POC and patch included)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 1.0.4
    • 1.0.2
    • library
    • Security Level: Public
    • None
    • Linux Centos

    Description

      When the client calls libcouchbase_create and then later calls libcouchbase_destroy, some memory is leaked. For a client with many threads that open and close couchbase sessions, this will lead to memory exhaustion. The leak is caused by the use of strdup() in setup_boostrap_hosts(). These duplicated strings are not free'd in libcouchbase_destroy. The leak can be seen by using valgrind.

      I have attached a proof of concept, and a patch with a proposed fix.

      I have only tested on 1.0.2, but other versions may be affected.

      Attachments

        1. leak.c
          0.9 kB
        2. memory_leak.patch
          1 kB
        For Gerrit Dashboard: CCBC-65
        # Subject Branch Project Status CR V

        Activity

          People

            avsej Sergey Avseyev
            jamesoc James
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty