<div dir="ltr"><div>I get a crash when calling the CopyLayer function.</div><div>Pseudo code:</div><div>char** options = CSLAddString(nullptr, "DST_SRSWKT=some_wkt");</div><div>ds->CopyLayer(srcLayer, "newname", options);</div><div>CSLDestroy(options);<br></div><div><br></div><div>Inside <span class="gmail-pl-en">GDALDataset::CopyLayer</span> the DST_SRSWKT option is removed from the list:</div><div>// Remove DST_WKT from option list to prevent warning from driver.<br>const int nSRSPos = CSLFindName(papszOptions, "DST_SRSWKT");<br>papszOptions = CSLRemoveStrings(papszOptions, nSRSPos, 1, nullptr);</div><div><br></div><div>But since this is the only option CSLDestroy is called on the options pointer.</div><div>So the CSLDestroy(options) after the copy causes a crash since the memory is deleted twice.</div><div><br></div><div>How is this supported to be handled? How can the caller know the options array has been destroyed by the CopyLayer function?</div><div><br></div><div>Kind regards,</div><div>Dirk<br></div><div><br></div></div>