Opened 11 years ago
Closed 11 years ago
#5004 closed defect (invalid)
CSLMerge core dumps when running on nitf image that does have RPC data
Reported by: | rubinj | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | 1.9.2 |
Severity: | normal | Keywords: | CSLMerge core dumps |
Cc: |
Description
CSLMerge core dumps when running on nitf image that does have RPC data. When I run this through valgrind on linux, I get an invalid free / delete in vg_replace_malloc.c : 325
#include "gdal.h" #include "gdal_priv.h" #include<map> #include<string> #include<iostream> using namespace std; int main(int argc, char argv) {
char rpcMD = NULL; char allMD = NULL;
GDALAllRegister(); string inputFile = argv[1]; GDALDataset *gdalDS = (GDALDataset *)GDALOpenShared( inputFile.c_str(), GA_ReadOnly ); if(gdalDS == NULL)
{
cerr << "Could not open with GDAL:" << inputFile << endl; return 1;
} GDALDriver* driver = gdalDS->GetDriver(); string format = GDALGetDriverShortName(driver); cout << "format=" << format << endl; allMD = ((GDALDataset*)gdalDS)->GetMetadata(); rpcMD = ((GDALDataset*)gdalDS)->GetMetadata("RPC"); This call causes crash allMD = CSLMerge(allMD,rpcMD);
return 0;
}
Change History (1)
comment:1 by , 11 years ago
Milestone: | 1.9.3 |
---|---|
Resolution: | → invalid |
Status: | new → closed |
This is a misuse of the API of CSLMerge()
/
The important thing is "papszOrig the original list, being modified.", but the return of GDALDataset::GetMetadata() should not be altered by the user application, hence the crash.
The fix is :