From aec7f60146f697e2dcba218d01d21fb7c6cc5074 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 23 Apr 2014 12:36:30 +0100 Subject: [PATCH] Added a hidden constructor to prevent accidental misuse of the MD5 class. --- modules/juce_cryptography/hashing/juce_MD5.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/juce_cryptography/hashing/juce_MD5.h b/modules/juce_cryptography/hashing/juce_MD5.h index 2878d96cda..f984cf5dc5 100644 --- a/modules/juce_cryptography/hashing/juce_MD5.h +++ b/modules/juce_cryptography/hashing/juce_MD5.h @@ -44,14 +44,14 @@ public: MD5() noexcept; /** Creates a copy of another MD5. */ - MD5 (const MD5& other) noexcept; + MD5 (const MD5&) noexcept; /** Copies another MD5. */ - MD5& operator= (const MD5& other) noexcept; + MD5& operator= (const MD5&) noexcept; //============================================================================== /** Creates a checksum for a block of binary data. */ - explicit MD5 (const MemoryBlock& data) noexcept; + explicit MD5 (const MemoryBlock&) noexcept; /** Creates a checksum for a block of binary data. */ MD5 (const void* data, size_t numBytes) noexcept; @@ -64,10 +64,10 @@ public: */ MD5 (InputStream& input, int64 numBytesToRead = -1); - /** Creates a checksum for a file. */ - explicit MD5 (const File& file); + /** Creates a checksum for the contents of a file. */ + explicit MD5 (const File&); - /** Creates a checksum from a UTF-8 buffer. + /** Creates a checksum of the characters in a UTF-8 buffer. E.g. @code MD5 checksum (myString.toUTF8()); @endcode @@ -108,6 +108,10 @@ private: void processData (const void*, size_t) noexcept; void processStream (InputStream&, int64); + // This private constructor is declared here to prevent you accidentally passing a + // String and having it unexpectedly call the constructor that takes a File. + explicit MD5 (const String&) JUCE_DELETED_FUNCTION; + JUCE_LEAK_DETECTOR (MD5) };