Opened 19 years ago
Closed 13 years ago
#1446 closed defect (wontfix)
Cannot draw() a MyGIS layer more than once
Reported by: | Owned by: | sdlime | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | MapServer C Library | Version: | 4.6 |
Severity: | normal | Keywords: | |
Cc: |
Description (last modified by )
When rendering layers that are sourced from a MyGIS (mysql) source, draw() cannot be called more than once. Doing so results in a Segmentation Fault. This phenomenon occurs because of the way MySQL connection parameters are parsed from the layer's 'connection' property. An examination of the code (around line 374 in mapmygis.c) shows that the connection parameters are parsed by this code: (1) delim = strdup(":"); (2) DB_HOST = strdup(strtok(layer->connection, delim)); (3) DB_USER = strdup(strtok(NULL, delim)); (4) DB_PASSWD = strdup(strtok(NULL, delim)); (5) DB_DATABASE = strdup(strtok(NULL, delim)); (6) DB_DATATYPE = strdup(strtok(NULL, delim)); This code works fine the first time draw() is called, however subsequent calls results in a SIGSEGV being thrown at line (3). This occurs because strtok() modifies its first argument (per the strtok() man page), resulting in layer- >connection being truncated at the first colon. When line (3) is encountered the SIGSEV in generated from libc because strtok() presumably returns NULL. Since the connection string is modified by the first run through this routine, subsequent calls fail. There are a variety of potential fixes, however, this is what I did: char* tempcon; ... ... delim = strdup(":"); tempcon=strdup(layer->connection); DB_HOST = strdup(strtok(tempcon, delim)); DB_USER = strdup(strtok(NULL, delim)); DB_PASSWD = strdup(strtok(NULL, delim)); DB_DATABASE = strdup(strtok(NULL, delim)); DB_DATATYPE = strdup(strtok(NULL, delim)); As a quickie solution I simply strdup() the layer->connection string to a temporary location then tokenize from there. This prevents corruption of the original connection string so that subsequent calls do not fail. Thank you to all of the developers for your hard work on this remarkable product. - Rob Parsons
Change History (1)
comment:1 by , 13 years ago
Description: | modified (diff) |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
mygis support has been removed. use ogr now.