mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-29 22:38:14 +00:00
Fixed a potential memory leak in md5 code; removed unused code
This commit is contained in:
parent
d0a586d240
commit
0a32b39e3a
42
src/md5.cpp
42
src/md5.cpp
@ -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!
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user