mirror of https://github.com/aria2/aria2
2008-12-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed memory leak in decoderawstring() * src/bencode.ccpull/1/head
parent
b618ada28a
commit
9b197e97d3
|
@ -1,3 +1,8 @@
|
|||
2008-12-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Fixed memory leak in decoderawstring()
|
||||
* src/bencode.cc
|
||||
|
||||
2008-12-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added missing #ifdef guard. Added uc() function for String and
|
||||
|
|
|
@ -335,19 +335,19 @@ static std::string decoderawstring(std::istream& ss)
|
|||
size_t length;
|
||||
ss >> length;
|
||||
if(!ss) {
|
||||
throw RecoverableException("Integer expected but none found.");
|
||||
throw RecoverableException("A positive integer expected but none found.");
|
||||
}
|
||||
// TODO check length, it must be less than or equal to INT_MAX
|
||||
checkdelim(ss);
|
||||
char* buf = new char[length];
|
||||
ss.read(buf, length);
|
||||
std::string str(&buf[0], &buf[length]);
|
||||
delete [] buf;
|
||||
if(ss.gcount() != static_cast<int>(length)) {
|
||||
throw RecoverableException
|
||||
(StringFormat("Expected %lu bytes of data, but only %d read.",
|
||||
static_cast<unsigned long>(length), ss.gcount()).str());
|
||||
}
|
||||
std::string str(&buf[0], &buf[length]);
|
||||
delete [] buf;
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue