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 <jeff.morriss.ws@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Jeff Morriss 2015-03-01 21:15:27 -05:00 committed by Anders Broman
parent f9f7ff2904
commit 701be1f052
1 changed files with 26 additions and 2 deletions

View File

@ -63,6 +63,7 @@
#include <epan/dissectors/packet-rtp.h>
#include <epan/rtp_pt.h>
#include <epan/prefs.h>
#include <wsutil/report_err.h>
#include <codecs/codecs.h>
@ -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;