1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fixed some undefined (or implementation defined) behavior

This commit is contained in:
tpoole 2017-08-24 09:13:49 +01:00
parent ba1cba9547
commit 9600016294
11 changed files with 106 additions and 96 deletions

View file

@ -450,13 +450,15 @@ public:
encryptDecryptTest (bf, data.getData(), data.getSize() - 8, data.getSize());
encryptDecryptTest (bf, data.getData(), 0, 8);
{
// Test unaligned data encryption/decryption. This will be flagged up by a check for
// undefined behaviour!
const uintptr_t nudge = static_cast<uintptr_t> (random.nextInt (sizeof(void*) - 1));
void* unalignedData = (void*) (reinterpret_cast<uintptr_t> (data.getData()) + nudge);
size_t newSize = data.getSize() - nudge;
// test unaligned data encryption/decryption
const uintptr_t nudge = static_cast<uintptr_t> (random.nextInt (sizeof(void*) - 1));
void* unalignedData = (void*) (reinterpret_cast<uintptr_t> (data.getData()) + nudge);
size_t newSize = data.getSize() - nudge;
encryptDecryptTest (bf, unalignedData, newSize - 8, newSize);
encryptDecryptTest (bf, unalignedData, newSize - 8, newSize);
}
}
}
};