Fixed a potential memory leak in md5 code; removed unused code

This commit is contained in:
Karol Nowak 2009-07-05 21:10:12 +00:00
parent d0a586d240
commit 0a32b39e3a
2 changed files with 3 additions and 42 deletions

View File

@ -254,9 +254,9 @@ MD5::MD5(std::ifstream& stream)
unsigned char *MD5::raw_digest(){
uint1 *s = new uint1[16];
unsigned char *MD5::raw_digest()
{
static uint1 s[16];
if (!finalized){
std::cerr << "MD5::raw_digest: Can't get digest if you haven't "<<
@ -268,44 +268,8 @@ unsigned char *MD5::raw_digest(){
return s;
}
char *MD5::hex_digest(){
int i;
char *s= new char[33];
if (!finalized){
std::cerr << "MD5::hex_digest: Can't get digest if you haven't "<<
"finalized the digest!" <<std::endl;
return (char *)("");
}
for (i=0; i<16; i++)
sprintf(s+i*2, "%02x", digest[i]);
s[32]='\0';
return s;
}
std::ostream& operator<<(std::ostream &stream, MD5 context){
stream << context.hex_digest();
return stream;
}
// PRIVATE METHODS:
void MD5::init(){
finalized=0; // we just started!

View File

@ -63,9 +63,6 @@ public:
// methods to acquire finalized result
unsigned char *raw_digest (); // digest as a 16-byte binary array
char * hex_digest (); // digest as a 33-byte ascii-hex string
friend std::ostream& operator<< (std::ostream&, MD5 context);
private: