From 72cc1eb4d4c980b813edcd06914e23587949865d Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 1 May 2010 18:07:56 +0000 Subject: [PATCH] Even safer datetime parsing --- src/misc.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/misc.cpp b/src/misc.cpp index 3d40370eb..ee75f8135 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -484,7 +484,12 @@ QString misc::magnetUriToHash(QString magnet_uri) { QString misc::boostTimeToQString(const boost::optional boostDate) { if(!boostDate || !boostDate.is_initialized() || boostDate->is_not_a_date_time()) return tr("Unknown"); - struct std::tm tm = boost::posix_time::to_tm(*boostDate); + struct std::tm tm; + try { + tm = boost::posix_time::to_tm(*boostDate); + } catch(std::exception e) { + return tr("Unknown"); + } time_t t = mktime(&tm); if(t < 0) return tr("Unknown");