Skip to content

Commit

Permalink
[cppapi] Use the right API to free stats strings. (#5366)
Browse files Browse the repository at this point in the history
[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.
  • Loading branch information
teo-tsirpanis authored Nov 11, 2024
1 parent 738f238 commit b224aee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tiledb/sm/cpp_api/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class Context {

// Copy `c_str` into `str`.
std::string str(c_str);
::free(c_str);
tiledb_stats_free_str(&c_str);

return str;
}
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/cpp_api/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ class Query {

// Copy `c_str` into `str`.
std::string str(c_str);
free(c_str);
tiledb_stats_free_str(&c_str);

return str;
}
Expand Down

0 comments on commit b224aee

Please sign in to comment.