Index: trunk/drivers/tkwin.c
===================================================================
--- trunk/drivers/tkwin.c	(revision 11384)
+++ trunk/drivers/tkwin.c	(working copy)
@@ -4,6 +4,9 @@
 //
 // Copyright (C) 2004  Maurice LeBrun
 // Copyright (C) 2004  Joao Cardoso
+// 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.
 //
@@ -487,13 +490,23 @@
     TkwDisplay *tkwd = (TkwDisplay *) dev->tkwd;
 
     PLINT      i;
-    XPoint     pts[PL_MAXPOLY];
+    XPoint     _pts[PL_MAXPOLY];
+    XPoint     *pts;
 
     if ( dev->flags & 1 )
         return;
-
+    
     if ( npts > PL_MAXPOLY )
-        plexit( "plD_polyline_tkw: Too many points in polyline\n" );
+    {
+        if ( ( pts = (XPoint *)malloc ( npts * sizeof ( XPoint ) ) ) == NULL )
+        {
+            plexit( "plD_polyline_tkw: Out of memory!" );
+        }
+    }
+    else
+    {
+        pts = _pts;
+    }
 
     for ( i = 0; i < npts; i++ )
     {
@@ -508,6 +521,11 @@
     if ( dev->write_to_pixmap )
         XDrawLines( tkwd->display, dev->pixmap, dev->gc, pts, npts,
             CoordModeOrigin );
+    
+    if ( npts > PL_MAXPOLY )
+    {
+        free( pts );
+    }
 }
 
 //--------------------------------------------------------------------------
@@ -838,11 +856,21 @@
 {
     TkwDev     *dev  = (TkwDev *) pls->dev;
     TkwDisplay *tkwd = (TkwDisplay *) dev->tkwd;
-    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;
+    }
 
 
     for ( i = 0; i < pls->dev_npts; i++ )
@@ -878,6 +906,11 @@
         XSetForeground( tkwd->display, dev->gc, dev->curcolor.pixel );
     }
 #endif
+
+    if ( pls->dev_npts > PL_MAXPOLY )
+    {
+        free( pts );
+    }
 }
 
 //--------------------------------------------------------------------------
