[GRASS-dev] more d.vect-kills-x0

Glynn Clements glynn at gclements.plus.com
Wed May 9 17:02:08 EDT 2007

Markus Neteler wrote:

> revisiting this bug report:
> http://intevation.de/rt/webrt?serial_num=5263&display=History
> I discovered that this sequence:
> # in spearfish:
> g.region rast=roads -a
> r.thin roads out=roads_thin
> r.to.vect -v input=roads_thin output=roads_thin_vect_cat feature=line
> g.region n=4922490 s=4921260 e=600300 w=598620 res=30 -a
> d.rast roads_thin
> d.vect -c roads_thin_vect_cat 
> kills the X monitor (the last line).

I can reproduce this.

plot1() calls D_polydots_clip() with n==1. If the point is outside the
clip region, D_polydots_clip() calls R_polydots_abs() with number==0. 
For the default COM_Polydots_{abs,rel}() implementations, this is a
no-op, but XDRIVER does:

	cur_x = xpnts[number - 1].x;
	cur_y = xpnts[number - 1].y;

xpnts is NULL (a zero-byte malloc() may return NULL), hence XDRIVER
segfaults and dies.

AFAICT, XDRIVER has always had this bug, but nothing ever tried to
draw zero dots before D_polydots_clip() was added.

I've added a test to XDRIVER's polydots/polyline/polygon
functions, which appears to fix the problem.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list