#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 , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 15 years ago
Milestone: | → 1.5.5 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Thanks for the report and fix!
Applied in trunk (r16196), branches/1.6 (r16197) and branches/1.5 (r16198).