From 701be1f052922aa00288a8c28c42ee358587b7fb Mon Sep 17 00:00:00 2001 From: Jeff Morriss Date: Sun, 1 Mar 2015 21:15:27 -0500 Subject: [PATCH] RTP player: don't crash when drawing channel graphs for very long calls. X11 can't handle pixmaps more than 32k pixels wide so don't try to feed it one. This avoids crashes with the complaint "BadAlloc (insufficient resources for operation)". Instead we simply truncate the graph (and tell the user). Do this in a way that shows the user the empty portion of the graph. Hopefully the Qt port can fix this properly. Note: the bug report says that MacOS is not affected but it should be. So apply this fix for all on-Windows systems. Bug: 2630 Change-Id: I71e1bd2f9a62792db06ce887e2bbe7a96d110e0a Reviewed-on: https://code.wireshark.org/review/7464 Petri-Dish: Jeff Morriss Reviewed-by: Anders Broman --- ui/gtk/rtp_player.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/ui/gtk/rtp_player.c b/ui/gtk/rtp_player.c index a765c1d404..3b0e0e2daa 100644 --- a/ui/gtk/rtp_player.c +++ b/ui/gtk/rtp_player.c @@ -63,6 +63,7 @@ #include #include #include +#include #include @@ -1232,7 +1233,8 @@ on_bt_check_clicked(GtkButton *button _U_, gpointer user_data) } /****************************************************************************/ -static void channel_draw(rtp_channel_info_t* rci) +static void +channel_draw(rtp_channel_info_t *rci) { int i, imax; int j; @@ -1643,6 +1645,17 @@ configure_event_channels(GtkWidget *widget, GdkEventConfigure *event _U_, gpoint rci->surface=NULL; } gtk_widget_get_allocation(widget, &widget_alloc); + +#if !defined(_WIN32) + /* Bug 2630: X11 can't handle pixmaps larger than 32k. Just truncate + * the graph for now (to avoid the crash). + */ + if (widget_alloc.width > G_MAXINT16-1) { + widget_alloc.width = G_MAXINT16-1; + report_failure("Channel graph truncated to 32k samples"); + } +#endif + rci->surface = gdk_window_create_similar_surface (gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR, widget_alloc.width, @@ -1659,6 +1672,17 @@ configure_event_channels(GtkWidget *widget, GdkEventConfigure *event _U_, gpoint rci->pixmap=NULL; } gtk_widget_get_allocation(widget, &widget_alloc); + +#if !defined(_WIN32) + /* Bug 2630: X11 can't handle pixmaps larger than 32k. Just truncate + * the graph for now (to avoid the crash). + */ + if (widget_alloc.width > G_MAXINT16-1) { + widget_alloc.width = G_MAXINT16-1; + report_failure("Channel graph truncated to 32k samples"); + } +#endif + rci->pixmap = gdk_pixmap_new(gtk_widget_get_window(widget), widget_alloc.width, widget_alloc.height, @@ -1761,7 +1785,7 @@ button_press_event_channel(GtkWidget *widget _U_, GdkEventButton *event _U_, gpo /****************************************************************************/ static void -add_channel_to_window(gchar *key _U_ , rtp_channel_info_t *rci, guint *counter _U_ ) +add_channel_to_window(gchar *key _U_ , rtp_channel_info_t *rci, guint *counter) { GString *label; GtkWidget *viewport;