powerrename: fix union usage (#42845)

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #42843
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
fix undefined behavior when using union in the `IFACEMETHODIMP
CPowerRenameRegEx::PutFileTime(_In_ SYSTEMTIME fileTime)` function

a69f7fa806/src/modules/powerrename/lib/PowerRenameRegEx.cpp (L299)

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
This commit is contained in:
safocl
2026-01-04 15:33:16 +04:00
committed by GitHub
parent 709c4bbf6b
commit 78b0139bc3

View File

@@ -344,19 +344,13 @@ IFACEMETHODIMP CPowerRenameRegEx::PutFlags(_In_ DWORD flags)
IFACEMETHODIMP CPowerRenameRegEx::PutFileTime(_In_ SYSTEMTIME fileTime)
{
union timeunion
{
FILETIME fileTime;
ULARGE_INTEGER ul;
};
FILETIME ft1;
FILETIME ft2;
timeunion ft1;
timeunion ft2;
SystemTimeToFileTime(&m_fileTime, &ft1);
SystemTimeToFileTime(&fileTime, &ft2);
SystemTimeToFileTime(&m_fileTime, &ft1.fileTime);
SystemTimeToFileTime(&fileTime, &ft2.fileTime);
if (ft2.ul.QuadPart != ft1.ul.QuadPart)
if (ft2.dwLowDateTime != ft1.dwLowDateTime || ft2.dwHighDateTime != ft1.dwHighDateTime)
{
m_fileTime = fileTime;
m_useFileTime = true;