Opened 15 years ago
Closed 15 years ago
#3008 closed defect (fixed)
Incorrect use of CPLSPrintf() in georaster driver
Reported by: | Even Rouault | Owned by: | ilucena |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: |
Description
Ivan,
the following code in georaster_dataset.cpp is unlikely to be correct:
while( poStmt->Fetch() ) { papszSubdatasets = CSLSetNameValue( papszSubdatasets, CPLSPrintf( "SUBDATASET_%d_NAME", nCount ), CPLSPrintf( "georaster:%s,%s,%s,%s%s%s", papszToken[0], papszToken[1], papszToken[2], papszToken[3], papszToken[4], papszToken[5] ) ); papszSubdatasets = CSLSetNameValue( papszSubdatasets, CPLSPrintf( "SUBDATASET_%d_DESC", nCount ), CPLSPrintf( "%s%s %s%s", papszToken[6], papszToken[7], papszToken[8], papszToken[9] ) ); nCount++; }
in the CSLSetNameValue() you provide 2 arguments with the return of CPLSPrintf(). But CPLSPrintf() return a (per thread) static buffer... So currently, you probably get the result of the first or second call as both the name and value.
To fix this, you should store the result of each CPLSprintf() in a CPLString for example, and the call CSLSetNameValue().
Note:
See TracTickets
for help on using tickets.
Committed revision 17146