Skip to content

Fix memory leak on error in C API create_column_family#14447

Open
omkarhgawde wants to merge 1 commit intofacebook:mainfrom
omkarhgawde:export-D95303444
Open

Fix memory leak on error in C API create_column_family#14447
omkarhgawde wants to merge 1 commit intofacebook:mainfrom
omkarhgawde:export-D95303444

Conversation

@omkarhgawde
Copy link
Contributor

Summary:
rocksdb_create_column_family() and
rocksdb_transactiondb_create_column_family() allocate a
rocksdb_column_family_handle_t but always return it even when
CreateColumnFamily() fails. This leaks the handle and returns an object
with an indeterminate rep pointer. Other similar functions like
rocksdb_create_column_family_with_import() correctly delete the handle
and return nullptr on error.

Fix: Initialize handle->rep = nullptr, check SaveError() return value,
and on error delete the handle and return nullptr.

Differential Revision: D95303444

Summary:
`rocksdb_create_column_family()` and
`rocksdb_transactiondb_create_column_family()` allocate a
`rocksdb_column_family_handle_t` but always return it even when
`CreateColumnFamily()` fails. This leaks the handle and returns an object
with an indeterminate `rep` pointer. Other similar functions like
`rocksdb_create_column_family_with_import()` correctly delete the handle
and return nullptr on error.

Fix: Initialize `handle->rep = nullptr`, check `SaveError()` return value,
and on error delete the handle and return nullptr.

Differential Revision: D95303444
@meta-cla meta-cla bot added the CLA Signed label Mar 10, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 10, 2026

@omkarhgawde has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95303444.

@github-actions
Copy link

✅ clang-tidy: No findings on changed lines

Completed in 54.2s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant