Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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>
  • Loading branch information
3 people committed Apr 15, 2021
1 parent e864683 commit 6d06cfa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
3 changes: 2 additions & 1 deletion mapdraw.c
Expand Up @@ -2837,7 +2837,7 @@ int computeMarkerBounds(mapObj *map, pointObj *annopoint, textSymbolObj *ts, lab
double aox,aoy;
symbolObj *symbol = map->symbolset.symbol[style->symbol];
if(msGetMarkerSize(map, style, &sx, &sy, ts->scalefactor) != MS_SUCCESS)
return MS_FALSE;
return -1; /* real error, different from MS_FALSE, return -1 so we can trap it */
if(style->angle) {
pointObj *point = poly->poly->point;
point[0].x = sx / 2.0;
Expand Down Expand Up @@ -3125,6 +3125,7 @@ int msDrawLabelCache(mapObj *map, imageObj *image)
break; /* the marker collided, break from multi-label loop */
}
}
if(have_label_marker == -1) return MS_FAILURE; /* error occured (symbol not found, etc...) */

if(textSymbolPtr->annotext) {
/*
Expand Down
11 changes: 0 additions & 11 deletions mapfile.c
Expand Up @@ -6637,17 +6637,6 @@ int msUpdateMapFromURL(mapObj *map, char *variable, char *string)
switch(msyylex()) {
case(MAP):
switch(msyylex()) {
case(CONFIG): {
char *key=NULL, *value=NULL;
if((getString(&key) != MS_FAILURE) && (getString(&value) != MS_FAILURE)) {
msSetConfigOption( map, key, value );
free( key );
key=NULL;
free( value );
value=NULL;
}
}
break;
case(EXTENT):
msyystate = MS_TOKENIZE_URL_STRING;
msyystring = string;
Expand Down
10 changes: 8 additions & 2 deletions mapraster.c
Expand Up @@ -984,16 +984,22 @@ imageObj *msDrawReferenceMap(mapObj *map)
char szPath[MS_MAXPATHLEN];
int status = MS_SUCCESS;

imageObj *image = NULL;
imageObj *image = NULL;
styleObj style;

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

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

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

Expand Down

0 comments on commit 6d06cfa

Please sign in to comment.