Skip to content

Set the last byte in allocated char array to zero [cherry picked from #650] #699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.11.3] - 11/30/2021

### Fixed

* Set the last byte in allocated char array to zero [cherry picked from #650] (#699)

## [0.11.2] - 11/29/2021

### Added
- Extending `dpctl.device_context` with nested contexts (#678)

## Fixed
### Fixed
- Fixed issue #649 about incorrect behavior of `.T` method on sliced arrays (#653)

## [0.11.1] - 11/10/2021
Expand Down
5 changes: 5 additions & 0 deletions dpctl-capi/helper/include/dpctl_string_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ cstring_from_string(const std::string &str)
#else
std::strncpy(cstr, str.c_str(), cstr_len);
#endif
// Added to resolve CheckMarx's false positive.
// NB: This is redundant because str.c_str() is guaranteed
// to be null-terminated and the copy function is asked to
// copy enough characters to include that null-character.
cstr[cstr_len - 1] = '\0';
} catch (std::bad_alloc const &ba) {
// \todo log error
std::cerr << ba.what() << '\n';
Expand Down