Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#1633 closed defect (fixed)

Function queryByRect returns resultsetmembers with negative classindex

Reported by: troppenhagen@… Owned by: mapserverbugs
Priority: high Milestone:
Component: MapScript-PHP Version: 4.4
Severity: major Keywords:


The MapScript-PHP method queryByRect returns some ResultCacheMemberObjects 
containing a negative classindex
if there are more than 128 classes defined in the queried layer.
The constant MS_MAXCLASSES in map.h is set to 250 but MapScript seems not to 
take account of it.
According to the description of method getClass the classindex starts with 0.
Using the method getClass with a negative classindex results in a returned NULL 

Change History (6)

comment:1 by dmorissette, 18 years ago

Cc: assefa@… steve.lime@… added
Owner: changed from mapserverbugs to dmorissette@…
I think this must be happening because classindex is defined as a char in the
resultCacheMemberObj definition in map.h. Everywhere else in the code it is used
as a 32 bits signed int, so what happens is that the range of the char variable
overflows, resulting in negative values:

typedef struct {
  long shapeindex;
  int tileindex;
  char classindex;
} resultCacheMemberObj;

I sugest changing this definition to use "int classindex". Is that okay with you
Steve? I would do that before the 4.8 release (in both 4.8 and 4.9-dev).

comment:2 by sdlime, 18 years ago

Owner: changed from dmorissette@… to mapserverbugs
Sounds like the right fix (that's a lot of classes). Do you want to make it or 
should I?


comment:3 by dmorissette, 18 years ago

Status: newassigned
Doing it now.

comment:4 by dmorissette, 18 years ago

Resolution: fixed
Status: assignedclosed
Fixed in both 4.8.0 and 4.9-dev in CVS

comment:5 by dmorissette, 18 years ago

Note that Sean pointed out that this change will impact on the format of the
files saved by msSaveQuery(). That should not be a problem unless there are
people using saved queries for longer than a given user's session. What do you
think Steve?

comment:6 by sdlime, 18 years ago

Sean's right, but as you say the impact is minimal given the duration of query 
files. I can't see them ever being written and then read by different versions 
of the software.

Note: See TracTickets for help on using tickets.