Skip to content

fix: use memset if memset_s is not available #107

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

Conversation

faviansamatha
Copy link
Contributor

@faviansamatha faviansamatha commented Apr 11, 2025

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:

  • Mac M2
  • Windows
  • Linux Ubuntu 24

Ran regression test on Windows and tests had same results as mainline prior to 105

@davecramer davecramer merged commit 33d15a9 into postgresql-interfaces:main Apr 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants