Skip to content

set the last byte in allocated char array to zero.#650

Merged
diptorupd merged 1 commit intomasterfrom
string-helper-ensure-null-termination
Nov 3, 2021
Merged

set the last byte in allocated char array to zero.#650
diptorupd merged 1 commit intomasterfrom
string-helper-ensure-null-termination

Conversation

@oleksandr-pavlyk
Copy link
Copy Markdown
Contributor

@oleksandr-pavlyk oleksandr-pavlyk commented Nov 2, 2021

Set the last byte of new array of chars to 0 to explicitly ensure null-termination.

Noting that the source of the copy, str.c_str() is always null-terminated (see c++-reference), the terminating character of the destination depends on how many bytes the strncpy_s actually copies.

Feel free to dismiss.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Nov 2, 2021

Coverage Status

Coverage remained the same at 74.511% when pulling 7985bfe on string-helper-ensure-null-termination into 73ef7b8 on master.

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the string-helper-ensure-null-termination branch 2 times, most recently from 342df7c to 4821508 Compare November 2, 2021 20:54
Comment thread dpctl-capi/helper/include/dpctl_string_utils.hpp Outdated
@oleksandr-pavlyk oleksandr-pavlyk force-pushed the string-helper-ensure-null-termination branch from 4821508 to 7985bfe Compare November 3, 2021 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants