Running gdal_translate under valgrind:
valgrind --leak-check=yes gdal_translate -of PNG test.xml /tmp/test.png
... on the following WMS input file which contains an invalid server URL:
<GDAL_WMS>
<Service name="WMS">
<Version>1.1.1</Version>
<ServerUrl>http://onearth.jpl.nasa.gov/wms.cgi_invalid?</ServerUrl>
<SRS>EPSG:4326</SRS>
<ImageFormat>image/jpeg</ImageFormat>
<Layers>modis,global_mosaic</Layers>
<Styles></Styles>
</Service>
<DataWindow>
<UpperLeftX>-180.0</UpperLeftX>
<UpperLeftY>90.0</UpperLeftY>
<LowerRightX>180.0</LowerRightX>
<LowerRightY>-90.0</LowerRightY>
<SizeX>1000</SizeX>
<SizeY>1000</SizeY>
</DataWindow>
<Projection>EPSG:4326</Projection>
<BandsCount>3</BandsCount>
</GDAL_WMS>
... results in the following errors (of course):
ERROR 1: IReadBlock failed at X offset 0, Y offset 0
ERROR 1: GetBlockRef failed at X block offset 0, Y block offset 0
ERROR 1: IReadBlock failed at X offset 0, Y offset 0
ERROR 1: GetBlockRef failed at X block offset 0, Y block offset 0
ERROR 1: IReadBlock failed at X offset 0, Y offset 0
ERROR 1: GetBlockRef failed at X block offset 0, Y block offset 0
libpng error: No IDATs written into file
... and in the following leaks being reported by valgrind:
==10800== 1,759 bytes in 81 blocks are possibly lost in loss record 89 of 97
==10800== at 0x401C7F3: operator new(unsigned) (vg_replace_malloc.c:164)
==10800== by 0x4DDD489: std::string::_Rep::_S_create(unsigned, unsigned, std::allocator<char> const&) (in /media/hda5/data-ubuntu/opt/fgs1/fgs/lib/libstdc++.so.6.0.7)
==10800== by 0x4DDD94F: (within /media/hda5/data-ubuntu/opt/fgs1/fgs/lib/libstdc++.so.6.0.7)
==10800== by 0x4DDDAFC: std::string::string(char const*, std::allocator<char> const&) (in /media/hda5/data-ubuntu/opt/fgs1/fgs/lib/libstdc++.so.6.0.7)
==10800== by 0x42B7798: VSIInstallMemFileHandler (cpl_vsi_mem.cpp:616)
==10800== by 0x42B4852: VSIFileManager::Get() (cpl_vsil.cpp:574)
==10800== by 0x42B4877: VSIFileManager::GetHandler(char const*) (cpl_vsil.cpp:587)
==10800== by 0x42B4B40: VSIReadDir (cpl_vsil.cpp:62)
==10800== by 0x427D514: GDALDriverManager::AutoLoadDrivers() (gdaldrivermanager.cpp:595)
==10800== by 0x416977E: GDALAllRegister (gdalallregister.cpp:75)
==10800== by 0x8049A4A: ProxyMain(int, char**) (gdal_translate.cpp:129)
==10800== by 0x804BEFF: main (gdal_translate.cpp:865)
It would be good to trap the errors and report a more meaningful error message to the user, but more importantly the leak needs to be tracked and fixed.