Skip to content

Commit

Permalink
avoid segfault on dbf with less records than shp (MapServer#4424)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Aug 21, 2012
1 parent 2645f64 commit 03183be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mapshape.c
Original file line number Diff line number Diff line change
Expand Up @@ -2554,6 +2554,9 @@ int msSHPLayerNextShape(layerObj *layer, shapeObj *shape)
continue; /* skip NULL shapes */
}
shape->values = msDBFGetValueList(shpfile->hDBF, i, layer->iteminfo, layer->numitems);
if(!shape->values) {
return MS_FAILURE;
}
shape->numvalues = layer->numitems;

filter_passed = MS_TRUE; /* By default accept ANY shape */
Expand Down
4 changes: 3 additions & 1 deletion mapxbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,10 @@ char **msDBFGetValueList(DBFHandle dbffile, int record, int *itemindexes, int nu

for(i=0; i<numitems; i++) {
value = msDBFReadStringAttribute(dbffile, record, itemindexes[i]);
if (value == NULL)
if (value == NULL) {
free(values);
return NULL; /* Error already reported by msDBFReadStringAttribute() */
}
values[i] = msStrdup(value);
}

Expand Down

0 comments on commit 03183be

Please sign in to comment.