aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-10-21 17:08:03 -0700
committerGuy Harris <guy@alum.mit.edu>2016-10-22 00:08:42 +0000
commit49cf42c571f3f94632957371ccd99533e71764ff (patch)
treebb22dad15fc5fa35300d0506ba4c72dffdcd5f11
parentb3363fbbdee8b785c849c24a265fdbe28c28f608 (diff)
localtime() can return NULL, even if it's unlikely.
ANSI C says it can return NULL - and, at least on Windows with the MSVC library, it *will* return null for dates prior to the Epoch. Check for a null return and handle it. Fixes CID 1374109. Change-Id: Ib18566d1a75e4109adb21834b157e87532fcac10 Reviewed-on: https://code.wireshark.org/review/18365 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--ui/qt/import_text_dialog.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/ui/qt/import_text_dialog.cpp b/ui/qt/import_text_dialog.cpp
index f20bc507dd..fdfbae2204 100644
--- a/ui/qt/import_text_dialog.cpp
+++ b/ui/qt/import_text_dialog.cpp
@@ -365,7 +365,10 @@ void ImportTextDialog::on_dateTimeLineEdit_textChanged(const QString &time_forma
time(&cur_time);
cur_tm = localtime(&cur_time);
- strftime(time_str, 100, ti_ui_->dateTimeLineEdit->text().toUtf8().constData(), cur_tm);
+ if (cur_tm != NULL)
+ strftime(time_str, sizeof time_str, ti_ui_->dateTimeLineEdit->text().toUtf8().constData(), cur_tm);
+ else
+ g_strlcpy(time_str, "Not representable", sizeof time_str);
ti_ui_->timestampExampleLabel->setText(QString(tr("Example: %1")).arg(time_str));
time_format_ok_ = true;
}