fix: use memset if memset_s is not available #107
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
A previous PR (#105) replaced the instances of memset with memset_s or SecureZeroMemory because there's a chance that compiler may remove these calls during optimization. However, this PR will break builds with compilers that do not have memset_s.
memset_s
was introduced in C11, but it is flagged as optional and many compilers like GCC do not implement this.For the time being, this commit will re-introduce memset if
memset_s
is not implemented in the compiler by checking__STDC_LIB_EXT1__
and defining__STDC_WANT_LIB_EXT1__
before the needed imports. (reference: https://en.cppreference.com/w/c/string/byte/memset).This commit also removes the changes in the unit test.
memset
should be safe in the unit tests. (previous implementaiton caused 2 unit tests to fail, (not ok 9 - result-conversions test output differs``not ok 40 - diagnostic test
) because it used memset with a non-zero value.Testing
Built on:
Ran regression test on Windows and tests had same results as mainline prior to 105