Opened 15 years ago

Closed 15 years ago

Last modified 11 years ago

#2810 closed defect (fixed)

AddStyle crashes

Reported by: ftrastour Owned by: Even Rouault
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

This bug was already signaled in ticket #2531; the summary of this ticket is good but not the content...

AddStyle inconsistently uses CPLString().Printf() and causes a crash.

Here is a fix :

GBool OGRStyleTable::AddStyle(const char *pszName, const char *pszStyleString) {

int nPos;

if (pszName && pszStyleString) {

if ((nPos = IsExist(pszName)) != -1)

return FALSE;

m_papszStyleTable = CSLAddString(m_papszStyleTable,

CPLString().Printf("%s:%s",pszName,pszStyleString));

return TRUE;

} return FALSE;

}

There is another potential wrong usage of CPLString().Printf in OGRStyleTable::IsExist.

A possible fix :

int OGRStyleTable::IsExist(const char *pszName) {

int i;

if (pszName == NULL)

return -1;

const char *pszNewString = CPLSPrintf("%s:",pszName);

for (i=0;i<CSLCount(m_papszStyleTable);i++) {

if (strstr(m_papszStyleTable[i],pszNewString) != NULL)

return i;

} return -1;

}

Change History (3)

comment:1 by Even Rouault, 15 years ago

Owner: changed from warmerdam to Even Rouault
Status: newassigned

comment:2 by Even Rouault, 15 years ago

Milestone: 1.5.5
Resolution: fixed
Status: assignedclosed

Thanks for the report and fix!

Applied in trunk (r16196), branches/1.6 (r16197) and branches/1.5 (r16198).

comment:3 by Even Rouault, 11 years ago

Milestone: 1.5.5

Milestone 1.5.5 deleted

Note: See TracTickets for help on using tickets.