Skip to content

Commit de800e4

Browse files
Set the last byte in allocated char array to zero [cherry picked from #650] (#699)
* set the last byte in allocated char array to zero. (#650) * Update CHANGELOG Co-authored-by: Oleksandr Pavlyk <oleksandr.pavlyk@intel.com>
1 parent 8f21b44 commit de800e4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.11.3] - 11/30/2021
10+
11+
### Fixed
12+
13+
* Set the last byte in allocated char array to zero [cherry picked from #650] (#699)
14+
915
## [0.11.2] - 11/29/2021
1016

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

14-
## Fixed
20+
### Fixed
1521
- Fixed issue #649 about incorrect behavior of `.T` method on sliced arrays (#653)
1622

1723
## [0.11.1] - 11/10/2021

dpctl-capi/helper/include/dpctl_string_utils.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ cstring_from_string(const std::string &str)
5050
#else
5151
std::strncpy(cstr, str.c_str(), cstr_len);
5252
#endif
53+
// Added to resolve CheckMarx's false positive.
54+
// NB: This is redundant because str.c_str() is guaranteed
55+
// to be null-terminated and the copy function is asked to
56+
// copy enough characters to include that null-character.
57+
cstr[cstr_len - 1] = '\0';
5358
} catch (std::bad_alloc const &ba) {
5459
// \todo log error
5560
std::cerr << ba.what() << '\n';

0 commit comments

Comments
 (0)