couchbase / couchbase/fleece

possible invalid usage of realloc

Open
#74 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
338
Forks
35
Avg merge
13h 41m
Merged PRs (30d)
3

Description

Here:

https://github.com/couchbaselabs/fleece/blob/60bfb99bfed50329a2a8c3a3fb0cacea074ea799/Fleece/Tree/MutableNode.hh#L332

operator new/delete defined as:

 static void* operator new(size_t size, unsigned capacity) {
            return ::operator new(size + capacity*sizeof(NodeRef));
        }

but then

 MutableInterior* grow() {
            assert_precondition(capacity() < kMaxChildren);
            auto replacement = (MutableInterior*)realloc(this,

should be malloc/free used instead of ::operator new in the first place,
to make it possible to use realloc here?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Fleece/Tree/MutableNode.hh around the linked operator new/delete definitions and MutableInterior::grow(). Check whether the allocation and deallocation methods are compatible with realloc, then verify the appropriate ownership behavior for growth. Done means resolving whether this usage is valid and making the allocation strategy consistent if it is not.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.