fix: use memset if memset_s is not available#107
Merged
davecramer merged 2 commits intopostgresql-interfaces:mainfrom Apr 15, 2025
Merged
fix: use memset if memset_s is not available#107davecramer merged 2 commits intopostgresql-interfaces:mainfrom
davecramer merged 2 commits intopostgresql-interfaces:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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_swas 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_sis 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.
memsetshould 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