Skip to content

Commit 6d06cfa

Browse files
MapServer-backport-botgithub-actions[bot]sdlime
authored
[Backport branch-7-6] Improved initial check on generating reference maps, avoid crash with label styles (symbol errors), removed dead code. (#6298)
* Fixes for a couple of things I ran into when doing an upgrade on app * Update mapraster.c Resolve merge conflict. Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Steve Lime <steve.lime@state.mn.us>
1 parent e864683 commit 6d06cfa

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

mapdraw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2837,7 +2837,7 @@ int computeMarkerBounds(mapObj *map, pointObj *annopoint, textSymbolObj *ts, lab
28372837
double aox,aoy;
28382838
symbolObj *symbol = map->symbolset.symbol[style->symbol];
28392839
if(msGetMarkerSize(map, style, &sx, &sy, ts->scalefactor) != MS_SUCCESS)
2840-
return MS_FALSE;
2840+
return -1; /* real error, different from MS_FALSE, return -1 so we can trap it */
28412841
if(style->angle) {
28422842
pointObj *point = poly->poly->point;
28432843
point[0].x = sx / 2.0;
@@ -3125,6 +3125,7 @@ int msDrawLabelCache(mapObj *map, imageObj *image)
31253125
break; /* the marker collided, break from multi-label loop */
31263126
}
31273127
}
3128+
if(have_label_marker == -1) return MS_FAILURE; /* error occured (symbol not found, etc...) */
31283129

31293130
if(textSymbolPtr->annotext) {
31303131
/*

mapfile.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6637,17 +6637,6 @@ int msUpdateMapFromURL(mapObj *map, char *variable, char *string)
66376637
switch(msyylex()) {
66386638
case(MAP):
66396639
switch(msyylex()) {
6640-
case(CONFIG): {
6641-
char *key=NULL, *value=NULL;
6642-
if((getString(&key) != MS_FAILURE) && (getString(&value) != MS_FAILURE)) {
6643-
msSetConfigOption( map, key, value );
6644-
free( key );
6645-
key=NULL;
6646-
free( value );
6647-
value=NULL;
6648-
}
6649-
}
6650-
break;
66516640
case(EXTENT):
66526641
msyystate = MS_TOKENIZE_URL_STRING;
66536642
msyystring = string;

mapraster.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,16 +984,22 @@ imageObj *msDrawReferenceMap(mapObj *map)
984984
char szPath[MS_MAXPATHLEN];
985985
int status = MS_SUCCESS;
986986

987-
imageObj *image = NULL;
987+
imageObj *image = NULL;
988988
styleObj style;
989989

990+
/* check to see if we have enough information to actually proceed */
991+
if(!map->reference.image || map->reference.height == 0 || map->reference.width == 0) {
992+
msSetError(MS_MISCERR, "Reference map configuration error.", "msDrawReferenceMap()");
993+
return NULL;
994+
}
990995

991996
rendererVTableObj *renderer = MS_MAP_RENDERER(map);
992997
rasterBufferObj *refImage = (rasterBufferObj*)calloc(1,sizeof(rasterBufferObj));
993998
MS_CHECK_ALLOC(refImage, sizeof(rasterBufferObj), NULL);
994999

9951000
if(MS_SUCCESS != renderer->loadImageFromFile(msBuildPath(szPath, map->mappath, map->reference.image),refImage)) {
996-
msSetError(MS_MISCERR,"error loading reference image %s","msDrawREferenceMap()",szPath);
1001+
msSetError(MS_MISCERR,"Error loading reference image %s.","msDrawReferenceMap()",szPath);
1002+
free(refImage);
9971003
return NULL;
9981004
}
9991005

0 commit comments

Comments
 (0)