Skip to content

Commit b224aee

Browse files
[cppapi] Use the right API to free stats strings. (#5366)
[SC-59016](https://app.shortcut.com/tiledb-inc/story/59016/cppapi-getting-context-and-query-stats-should-not-use-free) This PR updates to use `tiledb_stats_free_str` instead of `free` to free stats strings in the C++ API. Will fix failures for cases when the application's and the Core's `free` functions are different (such as when using debug-mode CRT on Windows with the prebuilt `tiledb.dll`). --- TYPE: BUG DESC: Fix heap corruption when getting context and query stats from C++ under certain circumstances.
1 parent 738f238 commit b224aee

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tiledb/sm/cpp_api/context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class Context {
236236

237237
// Copy `c_str` into `str`.
238238
std::string str(c_str);
239-
::free(c_str);
239+
tiledb_stats_free_str(&c_str);
240240

241241
return str;
242242
}

tiledb/sm/cpp_api/query.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ class Query {
991991

992992
// Copy `c_str` into `str`.
993993
std::string str(c_str);
994-
free(c_str);
994+
tiledb_stats_free_str(&c_str);
995995

996996
return str;
997997
}

0 commit comments

Comments
 (0)