Skip to content

Commit

Permalink
Merge branch 'branch-7-0'
Browse files Browse the repository at this point in the history
  • Loading branch information
szekerest committed Aug 6, 2016
2 parents 701ea31 + dd336bc commit 2374bb0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion mapmssql2008.c
Expand Up @@ -976,7 +976,11 @@ static int prepare_database(layerObj *layer, rectObj rect, char **query_string)
char buffer[10000] = "";

for(t = 0; t < layer->numitems; t++) {
#ifdef USE_ICONV
snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "convert(nvarchar(max), [%s]),", layer->items[t]);
#else
snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "convert(varchar(max), [%s]),", layer->items[t]);
#endif
}

if (layerinfo->geometry_format == MSSQLGEOMETRY_NATIVE)
Expand Down Expand Up @@ -1699,7 +1703,7 @@ int msMSSQL2008LayerGetShapeRandom(layerObj *layer, shapeObj *shape, long *recor

if (needLen > 0) {
/* allocate the buffer - this will be a null-terminated string so alloc for the null too */
valueBuffer = (char*) msSmallMalloc( needLen + 1 );
valueBuffer = (char*) msSmallMalloc( needLen + 2 );
if ( valueBuffer == NULL ) {
msSetError( MS_QUERYERR, "Could not allocate value buffer.", "msMSSQL2008LayerGetShapeRandom()" );
return MS_FAILURE;
Expand All @@ -1714,7 +1718,13 @@ int msMSSQL2008LayerGetShapeRandom(layerObj *layer, shapeObj *shape, long *recor
valueBuffer[retLen] = 0; /* null terminate it */

/* Pop the value into the shape's value array */
#ifdef USE_ICONV
valueBuffer[retLen + 1] = 0;
shape->values[t] = msConvertWideStringToUTF8((wchar_t*)valueBuffer, "UCS-2LE");
msFree(valueBuffer);
#else
shape->values[t] = valueBuffer;
#endif
} else
/* Copy empty sting for NULL values */
shape->values[t] = msStrdup("");
Expand Down

0 comments on commit 2374bb0

Please sign in to comment.