Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#2322 canvas postscript command core dumps on special polygon

final: 8.3.5
closed-invalid
5
2003-05-07
2003-05-07
Anonymous
No

Hi,

there is a bug in tkCanvPoly.c:PolygonToPostscript in
recent Tk Versions (tested 8.3.5, 8.4.2).

Create a polygon with two identical points and no
outline color (I know this seems to be nonsense,
but in my case it was absolutely needed).
Do a postscript command on the canvas and you get the
core dump (a color
NULL pointer is passed on from PolygonToPostscript to
Tk_PostscriptColor, where it is referenced)

15:09[wilm@rubin:ConStruct3]$ wish
.wishrc .wishrc .wishrc ...
% canvas .c
.c
% pack .c
% .c create polygon 10 20 10 20
1
% .c postscript
Segmentation fault

Setting the outline sets the color pointer to non-NULL:

15:41[wilm@rubin:ConStruct3]$ wish
.wishrc .wishrc .wishrc ...
% canvas .c
.c
% pack .c
% .c create polygon 10 20 10 20 -outline black
1
% .c postscript
%!PS-Adobe-3.0 EPSF-3.0
...

To avoid this create a polygon with 3 points (using two
different points
activates expansion to three points and cirumvents the
faulty if-clause as well):

16:04[wilm@rubin:ConStruct3]$ wish
.wishrc .wishrc .wishrc ...
% canvas .c
.c
% pack .c
% .c create polygon 10 20 10 20 10 20
1
% .c postscript
%!PS-Adobe-3.0 EPSF-3.0
...

The reason for this bu is the following:
If only two points exist, special case code is used to
create a line and the color
is not verfified to be valid.

To patch this just check if color==NULL in case
polyPtr->numPoints==2 and return TCL_OK
See attachment.

Andreas

Discussion

  • patch

     
    Attachments
    • status: open --> closed
     
    • status: closed --> closed-invalid
     
  • Logged In: YES
    user_id=79902

    While serious, this is not a bug in Tcl. Please resubmit to
    the tktoolkit project.