[GRASS5] [bug #3469] (grass) about i.class

Glynn Clements glynn at gclements.plus.com
Mon Aug 8 10:29:56 EDT 2005


Brad Douglas wrote:

> > this bug's URL: http://intevation.de/rt/webrt?serial_num=3469
> > -------------------------------------------------------------------------
> > 
> > Subject: about i.class

> > I am working with GRASS61, I try with i.class for supervised
> > classification. After drawing the region on image I click to the
> > Analyze region Menu, I get this error message
> > WARNING:PREPARE_SIGNATURE: DATA ERROR (CLICK MOUSE TO CONTINUE). It
> > seem that all the regions that I chose before now disappear. I try
> > again with GRASS57, the result is also the same. Can you solve this
> > problem for me? Thank you very much,

> I traced this back to INAME_LEN being changed from 30 to 256 in
> include/imagery.h.
> 
> This makes lib/vask/V_ques.c: V_ques() bomb out starting at line:
> 
> if ((length <= 0) || ((length + col) > 80)) ...
> 
> where the variable 'length' is passed in as INAME_LEN.
> 
> The program keeps running until it dies with a floating point exception.

The attached patch changes V_ques() so that it truncates the length so
that col + length <= 80 rather than returning an error. It also
requires the starting column to be less than 80, rather than less than
or equal to 80.

The caller doesn't actually check the return value of V_ques(), and I
suspect that this is quite common. Maybe V_ques() should just use
G_fatal_error()?

Or maybe the imagery stuff should be weaned off of vask altogether. 
AFAICS, the only code in 6.1 which still uses vask is:

	i.ortho.photo
	lib/imagery
	set_data
	r.le.setup
	v.transform

lib/edit also uses it, but lib/edit is only used by set_data.

-- 
Glynn Clements <glynn at gclements.plus.com>

-------------- next part --------------
Index: lib/vask/V_ques.c
===================================================================
RCS file: /grassrepository/grass51/lib/vask/V_ques.c,v
retrieving revision 2.0
diff -u -r2.0 V_ques.c
--- lib/vask/V_ques.c	9 Nov 2004 12:39:18 -0000	2.0
+++ lib/vask/V_ques.c	8 Aug 2005 12:29:42 -0000
@@ -92,18 +92,21 @@
 		V_error(msg) ;
 		return(-1) ;
 	}
-	if ((col < 0) || (col > 80))
+	if ((col < 0) || (col >= 80))
 	{
 		char msg[80];
 		sprintf (msg,"Illegal column (%d) in call to V_ques", col);
 		V_error(msg) ;
 		return(-1) ;
 	}
-	if ((length <= 0) || ((length + col) > 80))
+	if (length <= 0)
 	{
-		V_error("Length out of bounds in call to V_ques") ;
+		V_error("Negative length in call to V_ques") ;
 		return(-1) ;
 	}
+	if (length + col > 80)
+		length = 80 - col;
+
 	if ((var_type == 's') || (var_type == 'i') || (var_type == 'f')
 	||  (var_type == 'l') || (var_type == 'd'))
 	{


More information about the grass-dev mailing list