38 lines
1.0 KiB
Plaintext
38 lines
1.0 KiB
Plaintext
|
$OpenBSD: patch-src_Statistics_cpp,v 1.1 2012/02/22 07:54:26 dcoppa Exp $
|
||
|
|
||
|
Fix crash on truncated statistics.dat
|
||
|
(upstream git commit 5e3682f7efed13eb52e4358a2d91b0e381334120)
|
||
|
|
||
|
--- src/Statistics.cpp.orig Mon Jun 13 10:50:25 2011
|
||
|
+++ src/Statistics.cpp Tue Feb 21 17:15:40 2012
|
||
|
@@ -25,6 +25,7 @@
|
||
|
//
|
||
|
|
||
|
#include "Statistics.h" // Interface declarations
|
||
|
+#include "Logger.h"
|
||
|
|
||
|
#include <protocol/ed2k/ClientSoftware.h>
|
||
|
|
||
|
@@ -311,12 +312,16 @@ void CStatistics::Load()
|
||
|
|
||
|
s_totalSent = 0;
|
||
|
s_totalReceived = 0;
|
||
|
- if (f.Open(JoinPaths(theApp->ConfigDir, wxT("statistics.dat")))) {
|
||
|
- uint8_t version = f.ReadUInt8();
|
||
|
- if (version == 0) {
|
||
|
- s_totalSent = f.ReadUInt64();
|
||
|
- s_totalReceived = f.ReadUInt64();
|
||
|
+ try {
|
||
|
+ if (f.Open(JoinPaths(theApp->ConfigDir, wxT("statistics.dat")))) {
|
||
|
+ uint8_t version = f.ReadUInt8();
|
||
|
+ if (version == 0) {
|
||
|
+ s_totalSent = f.ReadUInt64();
|
||
|
+ s_totalReceived = f.ReadUInt64();
|
||
|
+ }
|
||
|
}
|
||
|
+ } catch (CSafeIOException e) {
|
||
|
+ AddLogLineN(e.what());
|
||
|
}
|
||
|
|
||
|
// Load old values from config
|