diff --git a/src/mapservutil.c b/src/mapservutil.c index b6a9393abc..efa34f6fd7 100644 --- a/src/mapservutil.c +++ b/src/mapservutil.c @@ -2002,8 +2002,8 @@ int msCGIDispatchQueryRequest(mapservObj *mapserv) { /* catch empty result set when web->empty is set (#6907) */ if (mapserv->map->web.empty != NULL || CPLGetConfigOption("MS_EMPTY", NULL) != NULL) { - int n=0; - for (int i=0; imap->numlayers; i++) { // count results + int n = 0; + for (int i = 0; i < mapserv->map->numlayers; i++) { // count results if (mapserv->map->layers[i]->resultcache) { n += mapserv->map->layers[i]->resultcache->numresults; }