summaryrefslogtreecommitdiff
path: root/ui/gtk/rtp_player.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-10-21 19:18:15 -0700
committerGuy Harris <guy@alum.mit.edu>2016-10-22 02:27:32 +0000
commit10ca4c7527122efde0300205deaa6c0143f07219 (patch)
tree5352128043afff3b586c4a314ab2d240aec36f6a /ui/gtk/rtp_player.c
parent49cf42c571f3f94632957371ccd99533e71764ff (diff)
downloadwireshark-10ca4c7527122efde0300205deaa6c0143f07219.tar.gz
More checks for localtime() and gmtime() returning NULL.
And some comments in the case where we're converting the result of time() - if your machine's idea of time predates January 1, 1970, 00:00:00 UTC, it'll crash on Windows, but that's not a case where a *file* can cause the problem due either to a bad file time stamp or bad time stamps in the file. Change-Id: I837a438e4b875dd8c4f3ec2137df7a16ee4e9498 Reviewed-on: https://code.wireshark.org/review/18369 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/gtk/rtp_player.c')
-rw-r--r--ui/gtk/rtp_player.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ui/gtk/rtp_player.c b/ui/gtk/rtp_player.c
index 7d051093ad..aaa029a51e 100644
--- a/ui/gtk/rtp_player.c
+++ b/ui/gtk/rtp_player.c
@@ -1303,7 +1303,10 @@ channel_draw(rtp_channel_info_t *rci)
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb_view_as_time_of_day))) {
seconds = rci->start_time_abs.secs + i * MULT / sample_rate;
timestamp = localtime(&seconds);
- g_snprintf(label_string, MAX_TIME_LABEL, "%02d:%02d:%02d", timestamp->tm_hour, timestamp->tm_min, timestamp->tm_sec);
+ if (timestamp != NULL
+ g_snprintf(label_string, MAX_TIME_LABEL, "%02d:%02d:%02d", timestamp->tm_hour, timestamp->tm_min, timestamp->tm_sec);
+ else
+ g_snprintf(label_string, MAX_TIME_LABEL, "XX:XX:XX");
} else {
g_snprintf(label_string, MAX_TIME_LABEL, "%.0f s", floor(nstime_to_sec(&rci->start_time_abs)) + i*MULT/sample_rate);
}
@@ -1451,7 +1454,10 @@ channel_draw(rtp_channel_info_t *rci)
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb_view_as_time_of_day))) {
seconds = rci->start_time_abs.secs + i * MULT / sample_rate;
timestamp = localtime(&seconds);
- g_snprintf(label_string, MAX_TIME_LABEL, "%02d:%02d:%02d", timestamp->tm_hour, timestamp->tm_min, timestamp->tm_sec);
+ if (timestamp != NULL)
+ g_snprintf(label_string, MAX_TIME_LABEL, "%02d:%02d:%02d", timestamp->tm_hour, timestamp->tm_min, timestamp->tm_sec);
+ else
+ g_snprintf(label_string, MAX_TIME_LABEL, "XX:XX:XX");
} else {
g_snprintf(label_string, MAX_TIME_LABEL, "%.0f s", floor(nstime_to_sec(&rci->start_time_abs)) + i*MULT/sample_rate);
}