[GRASS5] r.average/r.stats bug

Hi,

to my surprise I found r.average to be non-functional
with certain combinations of INT/FP maps:

Using Spearfish5.7 sample data:

GRASS 5.7.cvs:~ > r.stats -anC fields,elevation.10m
Segmentation fault

GRASS 5.7.cvs:~ > r.average base=fields cover=elevation.10m out=field.avgelev
r.average: ERROR running r.stats command

GRASS 5.7.cvs:~ > r.stats -anC fields,elevation.10m
Segmentation fault

GRASS 5.7.cvs:~ > r.info -t fields
datatype=CELL
GRASS 5.7.cvs:~ > r.info -t elevation.10m
datatype=DCELL

The problem is the -C flag for r.stats as used in r.average (and related
commands).

I found that the 'for' loop in r.stats/main.c tries to open a third
map which isn't there. At least the debugger stops in that row.

Not sure how to fix it, the loop is slightly different in r.patch which
also accepts more than one input map.

Assistance appreciated,

Markus