From 0ee9586f0c767f2ee5c742507a79d4199dbb99f4 Mon Sep 17 00:00:00 2001 From: hobbs Date: Sat, 3 Jun 2000 08:38:11 +0000 Subject: * canvas.test: added test for 5783. * generic/tkCanvPoly.c (DisplayPolygon): added checks for the polygon fillGC not being empty to prevent segfault. [Bug: 5783] --- generic/tkCanvPoly.c | 7 ++++--- tests/canvas.test | 14 +++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index 79ba527..3b6568e 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -5,11 +5,12 @@ * * Copyright (c) 1991-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright (c) 1998-2000 Ajuba Solutions. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvPoly.c,v 1.5 2000/02/01 11:41:09 hobbs Exp $ + * RCS: @(#) $Id: tkCanvPoly.c,v 1.6 2000/06/03 08:38:12 hobbs Exp $ */ #include @@ -916,7 +917,7 @@ DisplayPolygon(canvas, itemPtr, display, drawable, x, y, width, height) * read-only. */ - if (stipple != None) { + if ((stipple != None) && (polyPtr->fillGC != None)) { Tk_TSOffset *tsoffset = &polyPtr->tsoffset; int w=0; int h=0; int flags = tsoffset->flags; @@ -991,7 +992,7 @@ DisplayPolygon(canvas, itemPtr, display, drawable, x, y, width, height) } } Tk_ResetOutlineGC(canvas, itemPtr, &(polyPtr->outline)); - if (stipple != None) { + if ((stipple != None) && (polyPtr->fillGC != None)) { XSetTSOrigin(display, polyPtr->fillGC, 0, 0); } } diff --git a/tests/canvas.test b/tests/canvas.test index 86da456..a3baa20 100644 --- a/tests/canvas.test +++ b/tests/canvas.test @@ -3,10 +3,10 @@ # standard fashion for Tcl tests. # # Copyright (c) 1995-1996 Sun Microsystems, Inc. -# Copyright (c) 1998-1999 by Scriptics Corporation. +# Copyright (c) 1998-2000 Ajuba Solutions. # All rights reserved. # -# RCS: @(#) $Id: canvas.test,v 1.8 2000/03/29 00:09:06 ericm Exp $ +# RCS: @(#) $Id: canvas.test,v 1.9 2000/06/03 08:38:11 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -319,7 +319,7 @@ test canvas-10.7 {check errors from tag expressions} { canvas .c .c create oval 20 20 40 40 -fill red -tag [list a b c d] .c create oval 20 260 40 280 -fill bisque -tag [list d "tag with spaces"] - catch {.c find withtag {d&&"tag with spaces}} err + catch {.c find withtag "d&&\"tag with spaces"} err set err } {Missing endquote in tag search expression} test canvas-10.8 {check errors from tag expressions} { @@ -359,6 +359,14 @@ test canvas-10.12 {multple events bound to same tag expr} { .c bind {a && b} {puts Leave} } {} +test canvas-11.1 {canvas poly fill check, bug 5783} { + # This would crash in 8.3.0 and 8.3.1 + destroy .c + pack [canvas .c] + .c create polygon 0 0 100 100 200 50 \ + -fill {} -stipple gray50 -outline black +} {} + # cleanup ::tcltest::cleanupTests return -- cgit v0.12