Index: trunk/drivers/xwin.c
===================================================================
--- trunk/drivers/xwin.c	(revision 11384)
+++ trunk/drivers/xwin.c	(working copy)
@@ -6,6 +6,9 @@
 // Copyright (C) 2004  Joao Cardoso
 // Copyright (C) 2004  Rafael Laboissiere
 // Copyright (C) 2004  Andrew Ross
+// 2010-12-23, José Luis García Pallero, jgpallero@gmail.com
+//             Change static vectors of length PL_MAXPOLY to dynamic via
+//             malloc/free functions
 //
 // This file is part of PLplot.
 //
@@ -421,10 +424,20 @@
     XwDisplay *xwd = (XwDisplay *) dev->xwd;
 
     PLINT     i;
-    XPoint    pts[PL_MAXPOLY];
-
+    XPoint    _pts[PL_MAXPOLY];
+    XPoint    *pts;
+    
     if ( npts > PL_MAXPOLY )
-        plexit( "plD_polyline_xw: Too many points in polyline\n" );
+    {
+        if ( ( pts = (XPoint *)malloc ( npts * sizeof ( XPoint ) ) ) == NULL )
+        {
+            plexit( "plD_polyline_xw: Out of memory!" );
+        }
+    }
+    else
+    {
+        pts = _pts;
+    }
 
     dbug_enter( "plD_polyline_xw" );
 
@@ -453,6 +466,11 @@
     if ( usepthreads )
         pthread_mutex_unlock( &events_mutex );
 #endif
+
+    if ( npts > PL_MAXPOLY )
+    {
+        free( pts );
+    }
 }
 
 //--------------------------------------------------------------------------
@@ -830,11 +848,21 @@
 {
     XwDev     *dev = (XwDev *) pls->dev;
     XwDisplay *xwd = (XwDisplay *) dev->xwd;
-    XPoint    pts[PL_MAXPOLY];
+    XPoint    _pts[PL_MAXPOLY];
+    XPoint    *pts;
     int       i;
-
+    
     if ( pls->dev_npts > PL_MAXPOLY )
-        plexit( "FillPolygonCmd: Too many points in polygon\n" );
+    {
+        if ( ( pts = (XPoint *)malloc ( pls->dev_npts * sizeof ( XPoint ) ) ) == NULL )
+        {
+            plexit( "FillPolygonCmd: Out of memory!" );
+        }
+    }
+    else
+    {
+        pts = _pts;
+    }
 
     CheckForEvents( pls );
 
@@ -871,6 +899,11 @@
         XSetForeground( xwd->display, dev->gc, dev->curcolor.pixel );
     }
 #endif
+
+    if ( pls->dev_npts > PL_MAXPOLY )
+    {
+        free( pts );
+    }
 }
 
 //--------------------------------------------------------------------------
